Problem Statement – Modify the GPA Calculation program so that you input your grades from a file, Grades.txt.  To include file I/O to your program, you must complete the following five steps: Include the header file fstream in the program. Declare file stream variable, ifstream inFile; Associate the file stream variable with the I/O source. Use the file stream variable with the extractor variable >> to get

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.3: Random File Access
Problem 6E
icon
Related questions
Question

Problem Statement – Modify the GPA Calculation program so that you input your grades from a file, Grades.txt.  To include file I/O to your program, you must complete the following five steps:

  1. Include the header file fstream in the program.
  2. Declare file stream variable, ifstream inFile;
  3. Associate the file stream variable with the I/O source.
  4. Use the file stream variable with the extractor variable >> to get input.
  5. Close the file.

Be sure to include the additional comments for the file manipulation program statements. Please read chapter 3 on file manipulation to see a program that includes these instructions and look at supplementary slides in Module 5 in Materials and Resources.

 

You are also to create an input file and save it as Grades.txt using the tool NotePad.  The file should have the following data in it:

Student #: 1001

Homework scores: 0, 0, 0

Quiz scores: 0, 0, 0

Program scores: 0, 0, 0

test scores: 0, 0, 0

Final Score: 0

 

Student #: 1002

Homework scores: 50, 50, 50

Quiz scores: 20, 20, 20

Program scores: 100, 100, 100

test scores: 100, 100, 100

Final Score: 120

 

Student #: 1003

Homework scores: 50, 25, 50

Quiz scores: 20, 15, 20

Program scores: 100, 90, 90

test scores: 100, 75, 65

Final Score: 90

In this file, the first line of the file is the student number, the second line contains the homework scores, the third line contains the quiz scores, the fourth line contains the program scores, the fifth line contains the test scores, and the sixth line contains the final score.  You may modify the lines to reflect how you read information in from the standard I/O device.

 

 

 

Additionally, you should use a looping control structure to read in the data from the file.   You are also to add a selection statement (one way or if else if statements) to find out the letter grade associated with your GPA.  For example, if your GPA is equivalent to 91.50, then the letter grade would be a "A".  You are then to add a switch statement to print out the letter grade. Letter grades can be either A, B, C, D or F.   For example, "Your grade that you earned is A".  

Prior to printing the letter grade, you must print your calculated GPA.

 

The output from the program should be as follows for each of the students:

 

The GPA for student 1002:  100

The earned letter grade:  A.

 

Remember to test your program by including the Grade.txt file in the same directory as your program.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr