C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 8, Problem 6PE
Program Plan Intro

Program Plan:

  1. Include necessary header files: iostream, fstream, string, and iomanip.
  2. Define the main() function.
  3. Declare the necessary variables:
    1. An ifstream object to read the input file.
    2. A string variable to hold the correct test answers.
    3. A string variable to hold each line of student data.
    4. A string variable to hold the student ID.
    5. A string variable to hold the student's answers to the test.
    6. An integer variable to hold the student's score.
    7. An integer variable to hold the number of questions the student didn't answer.
    8. An integer variable to hold the total number of questions.
    9. A double variable to hold the percentage score.
    10. A char variable to hold the student's grade.
  4. Open the input file using the ifstream object.
  5. Read the first line of the file, which contains the correct test answers, and store them in the testAnswers variable.
  6. Use a loop to read each subsequent line of the file:
    1. Extract the student ID and answers from the line using the substr() method.
    2. Initialize the score and notAnswered variables to 0.
    3. Loop through each answer and compare it to the corresponding correct answer:
    4. If the answer is correct, increase the score by 2.
    5. If the answer is incorrect, decrease the score by 1.
    6. If the question wasn't answered, increment the notAnswered variable.
    7. Calculate the percentage score and determine the student's grade based on the percentage score.
    8. Output the student's ID, their answers, their score, their percentage score, and their grade to the console.
  7. Close the input file.
  8. End the main() function and the program.

Program Description:

To read student answers from a text file compare them to the correct answers and calculate the students' scores and grades.

Blurred answer
Students have asked these similar questions
Ideal MOSFET Current–Voltage Characteristics—NMOS Device and draw the circuit
1. Create a Person.java file. Implement the public Person and Student classes in Person.java, including all the variables and methods in the UMLS. Person -name: String -street: String -city: String +Person(String name, String, street, String, city) +getName(): String +setName(String name): void +getStreet(): String +setStreet(String street): void +getCity(): String +setCity(String City): void +toString(): String Student -Id: int +Person(String name, String, street, String, city, int Id) +getId(): int +setId(int Id): void +toString(): String 2. Create a StudentTest.java file. Implement a public StudentTest class with a main method. In the main method, create one student object and print the object using System.out.println(). Your printing result must follow the example output: name: Mike, street: Morris Ave, city: Union, Id: 1000 Hint: You need to modify the toString methods in the Student class and Person class!
1) Apply the Paint Blue algorithm discussed in class to the following Finite Automata. a a a b b a COIS-3050H-R-W01-2025WI-COMB Formal Languages & Automata a b Show the status of the Finite Automata at the conclusion of the Paint Blue Algorithm (mark the visited states with an X and only include edges that have not been followed). 2) Use the pumping lemma to prove the following language is nonregular: L= {ab} = {abbb, aabbbbbb, aaabbbbbbbbb, ...}
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY