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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education