The (grades.txt) after exection needs to be single lines.  (See attachment) The expected output is also attached Here is the question: This program will have three functions, the main() create() and retrieve(). main() will call create() and then call retrieve() create() will prompt the user to enter any number of course name / grade pairs and write them to a file named grades.txt. Pressing Enter with no input value on the course name will exit the loop, close the file, print "File was created and closed" and return the bool value True to the main() retrieve()  will open and read grades.txt. The function then will print the course names and scores as shown below. The average score should be calculated as well as a simple GPA and displayed  to two decimal places and then return variable used for the GPA to the main() . See sample run below in which 4 course names were entered, but note that more or fewer courses could have been entered.

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

The (grades.txt) after exection needs to be single lines.  (See attachment)

The expected output is also attached

Here is the question:

This program will have three functions, the main() create() and retrieve().

main() will call create() and then call retrieve()

create() will prompt the user to enter any number of course name / grade pairs and write them to a file named grades.txt. Pressing Enter with no input value on the course name will exit the loop, close the file, print "File was created and closed" and return the bool value True to the main()

retrieve()  will open and read grades.txt. The function then will print the course names and scores as shown below. The average score should be calculated as well as a simple GPA and displayed  to two decimal places and then return variable used for the GPA to the main() . See sample run below in which 4 course names were entered, but note that more or fewer courses could have been entered.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage