EBK C++ PROGRAMMING: FROM PROBLEM ANALY
EBK C++ PROGRAMMING: FROM PROBLEM ANALY
8th Edition
ISBN: 9781337514491
Author: Malik
Publisher: CENGAGE LEARNING - CONSIGNMENT
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
Find the Error: date_string = input('Enter a date in the format mm/dd/yyyy: ') date_list = date_string.split('-') month_num = int(date_list[0]) day = date_list[1] year = date_list[2] month_name = month_list[month_num - 1] long_date = month_name + ' ' + day + ', ' + year print(long_date)
Find the Error:       full_name = input ('Enter your full name: ')       name = split(full_name)       for string in name:         print(string[0].upper(), sep='', end='')         print('.', sep=' ', end='')
Please show the code for the Tikz figure of the complex plane and the curve C. Also, mark all singularities of the integrand.
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