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
Draw the NFA for this
What are three examples each of closed-ended, open-ended, and range-of-response questions? thank you
Create 2 charts using this data. One without using wind speed and one including max speed in mph. Write a Report and a short report explaining your visualizations and design decisions. Include the following: Lead Story: Identify the key story or insight based on your visualizations. Shaffer’s 4C Framework: Describe how you applied Shaffer’s 4C principles in the design of your charts. External Data Integration: Explain the second data and how you integrated it with the Halloween dataset. Compare the two datasets. Attach screenshots of the two charts (Bar graph or Line graph) The Shaffer 4 C’s of Data Visualization Clear - easily seen; sharply defined• who's the audience? what's the message? clarity more important than aestheticsClean - thorough; complete; unadulterated, labels, axis, gridlines, formatting, right chart type, colorchoice, etc.Concise - brief but comprehensive. not minimalist but not verboseCaptivating - to attract and hold by beauty or excellence does it capture…
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