Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Learning Objectives: more practice with formatted user input and output writing formatted data to a text file use of a Sentinel Controlled Loop to solve

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Learning Objectives: more practice with formatted user input and output writing formatted data to a text file use of a Sentinel Controlled Loop to solve a problemy use of the Summation Loop Stratery to solve a problem General Description: write a program that asks the user for data on courses for a semester calculates the GPA and writes a report to a file as shown below. First, the program opens a file for writing called "erades. When the file fails to open, a message "Unable to open file grades.tatis printed and the program ends immediately The program next as the user to enter the student's name, which may have spaces. It then writes the "header" portion of the report The program then uses a Sentinel Controlled Looping strategy, asking the user to enter a course ID (na Spacesor "one to quit entering more details assumed the user enters data for at least one course. When done is entered the looping ends. When a Course ID is entered, the program: asks the user to enter the credit hours for the course asks the user to enter the letter grade for the course You may use only the first character of the user's input, and upper case it: char grade-toupper(inputGradestring) calculates the quality Point Value of the letter grade A-4,-3, C2, D-1, anything else 0 calculates the Quality Points Earned for the course (OPV Hours) keeps a sum of Total Quality Pointes Earned and Total Hours Earned After done entered the GPA is calculated TotOPE / TotHours and the footer is written to the output file as shown in the example Finally, the program doses the output fie prints "Grade report written to grades.txt" and ends the program Formatting the formatting of the user interaction on the Console should look as it does in the sample below, including blank lines and lining up of inputs. The formatting of the output file should look as it does in the example output file Enter student name: Ada Byron GRADE REPORT FOR: Ada Byron Course Grd Hrs QPts Enter Course (or done): CS215 Enter number of hours: 4 CS215 A 4 16 Enter grade (A,B,C,D,E): A KHS101 E 1 @ Enter Course (or done): KHS101 CHEM101 B 4 12 Enter number of hours: 1 ART222 D 2 2 Enter grade (A,B,C,D,E): E EGR 101 Enter Course (or done): CHEM101 EGR 192 C 2 Enter number of hours: 4 Enter grade (A,B,C,D,E): B Overall: 14 34 GPA: 2.43 Enter Course (or done): ART222 Enter number of hours: 2 Enter grade (A,B,C,0,0): D Enter Course (or done): EGR 101 Enter number of hours: 1 Enter grade (A,B,C,D,E): ? Enter Course (or done): EGR 182 Enter number of hours: 2 Enter grade (A,B,C,D,E): C Enter Course (or done): done rade report written torrades.txt Grading Rubrics: standard comment box at the top of the code opens output file and checks for failure correctly asks for student name and writes report header to file correctly asks for courses ends processing when done entered continues processing when other is entered asks for hours and grade correctly calculates GPV, OPE. Total OPE, Total Hours and GPA correctly weites report footer correctly dost, writes ending message, and returns at the end of the program Learning Objectives: more practice with formatted user input and output writing formatted data to a text file use of a Sentinel Controlled Loop to solve a problemy use of the Summation Loop Stratery to solve a problem General Description: write a program that asks the user for data on courses for a semester calculates the GPA and writes a report to a file as shown below. First, the program opens a file for writing called "erades. When the file fails to open, a message "Unable to open file grades.tatis printed and the program ends immediately The program next as the user to enter the student's name, which may have spaces. It then writes the "header" portion of the report The program then uses a Sentinel Controlled Looping strategy, asking the user to enter a course ID (na Spacesor "one to quit entering more details assumed the user enters data for at least one course. When done is entered the looping ends. When a Course ID is entered, the program: asks the user to enter the credit hours for the course asks the user to enter the letter grade for the course You may use only the first character of the user's input, and upper case it: char grade-toupper(inputGradestring) calculates the quality Point Value of the letter grade A-4,-3, C2, D-1, anything else 0 calculates the Quality Points Earned for the course (OPV Hours) keeps a sum of Total Quality Pointes Earned and Total Hours Earned After done entered the GPA is calculated TotOPE / TotHours and the footer is written to the output file as shown in the example Finally, the program doses the output fie prints "Grade report written to grades.txt" and ends the program Formatting the formatting of the user interaction on the Console should look as it does in the sample below, including blank lines and lining up of inputs. The formatting of the output file should look as it does in the example output file Enter student name: Ada Byron GRADE REPORT FOR: Ada Byron Course Grd Hrs QPts Enter Course (or done): CS215 Enter number of hours: 4 CS215 A 4 16 Enter grade (A,B,C,D,E): A KHS101 E 1 @ Enter Course (or done): KHS101 CHEM101 B 4 12 Enter number of hours: 1 ART222 D 2 2 Enter grade (A,B,C,D,E): E EGR 101 Enter Course (or done): CHEM101 EGR 192 C 2 Enter number of hours: 4 Enter grade (A,B,C,D,E): B Overall: 14 34 GPA: 2.43 Enter Course (or done): ART222 Enter number of hours: 2 Enter grade (A,B,C,0,0): D Enter Course (or done): EGR 101 Enter number of hours: 1 Enter grade (A,B,C,D,E): ? Enter Course (or done): EGR 182 Enter number of hours: 2 Enter grade (A,B,C,D,E): C Enter Course (or done): done rade report written torrades.txt Grading Rubrics: standard comment box at the top of the code opens output file and checks for failure correctly asks for student name and writes report header to file correctly asks for courses ends processing when done entered continues processing when other is entered asks for hours and grade correctly calculates GPV, OPE. Total OPE, Total Hours and GPA correctly weites report footer correctly dost, writes ending message, and returns at the end of the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions