In: Computer Science
Write a C++ program named, myGrade.cpp, that calculates a letter
grade for a student of this course (CSC100 online) based on three
user inputs. This program should begin by printing the title of the
application (program) and a brief description of what it does.
(Note: this is NOT the same as the program prolog: a prolog is much
more detailed, has required elements, and is intended for other
programmers reading the cpp file. The title and description
displayed by the program are meant for the user of the
program.)
Next, the program must prompt the user for three integer inputs in
the following order: 1) Points earned on programming assignments,
2) Points earned on MPL homework, and 3) Points earned on the final
exam. Each prompt should be clear, concise, and free of spelling
errors. After getting all three of the integer inputs, the program
should either print an input validation error message and then
terminate or output the required data for this program.
If an input error is detected, one and only one of the following
error messages should be displayed:
After displaying one of these error messages, the program should
terminate after displaying:
myGrade is now terminating.
Only if there is no input error would the program continue normal
execution. This means that the next step after all three inputs are
validated is to make the necessary calculations and determinations
to display the following items of information to the user in this
order:
Each numeric value displayed should be preceded by a clear,
concise label stating what the number means. The total points
earned is the sum of the three integers input by the user. The
letter grade is determined by matching the total points to the
correct row in the table given under the Grading section in the
Syllabus. Your code will need to implement efficient grade range
checks to determine the appropriate letter grade based on the table
in the syllabus. Use named constants for the grade range boundaries
(900, 800, etc.) and store the determined letter grade as an upper
case letter in variable of type, char. Do not use any variables of
type, double, in this program: double is not needed since all
entries are integers and the grade range boundaries are integers.
Your program must also implement the course rule that automatically
assigns a letter grade of F when the Final Exam points earned are
less then 240, i.e., 60% of the total possible.
Your program must use a switch statement on the letter grade (type,
char) to print one and only one of the following support
messages:
Once all six items of information are displayed (in the order
listed above), the program should terminate after
displaying:
myGrade is now terminating.
TRUE for THIS and ALL programs submitted in this course:
Avoid unnecessary point deductions by formatting your code AND
following ALL pertinent coding conventions. Make sure all
requirements are implemented. Make sure the program does not
calculate or display anything that is NOT required. Remember named
constants.
Example of Output:
Example output from your program if the three inputs were: 305 (programming assignments), 108 (MPL Homework), and 288 (Final Exam):
Programming Assignment points entered: 305
MPL Homework points
entered
108
Final Exam points
entered:
288
Total number of points earned:
701
Student's letter grade
earned: C
Ok, you passed, but you may be challenged
in CSC205.
Example output from your program if the three inputs were: 400 (programming assignments), 200 (MPL Homework), and 239 (Final Exam):
Programming Assignment points entered: 400
MPL Homework points
entered 200
Final Exam points entered:
239
Total number of points earned: 839
Student's letter grade
earned:
F
You did not score enough points on
the Final Exam to pass this course.
Example output from your program if the three inputs were: 275 (programming assignments), 80 (MPL Homework), and 240 (Final Exam):
Programming Assignment points entered: 275
MPL Homework points
entered
80
Final Exam points entered:
240
Total number of points earned: 595
Student's letter grade
earned:
F
You did not put forth enough effort
to pass this course.
Example output from your program if the three inputs were: -348 (programming assignments), 139 (MPL Homework), and 300 (Final Exam):
Programming Assignment points entered: -348
MPL Homework points
entered
139
Final Exam points
entered:
300
The number of points entered for the Programming Assignments must
be between 0 and 400, inclusive.
All I have so far is this and I am stuck on what to do:
#include <iostream>
using namespace std;
int main()
{
const int possible = 1000;
const int ASSIGNMENT = 400;
const int HW = 200;
const int FINAL = 400;
const int A = 90;
const int B = 80;
const int C = 70;
const int D = 60;
const int F = 59;
int assignment;
int MPLHomework;
int FinalExam;
int grade;
int total;
//Stating the name of the program and what it does
cout << "Welcome to the Grade Calculator" <<
endl;
cout << "The following program will calculate your
grade\n";
cout << "in CSC205 by averaging three inputs such
as\n";
cout << "your points from programming assignments, MPL
homework, and the final exam." << endl;
//Receiving user input
cout << "Please enter the amount of points for your
Programming Assignments:" << assignment << endl;
cin >> assignment;
cout << "Please enter the amount of points for your MPL
Homework:" << MPLHomework << endl;
cin >> MPLHomework;
cout << "Please enter the amount of points for your Final
Exam:" << FinalExam << endl;
cin >> FinalExam;
total = FinalExam + assignment + MPLHomework;
if (assignment <= ASSIGNMENT && MPLHomework <= HW
&& FinalExam <= FINAL)
cout << "Programming Assignment points entered:" <<
assignment << endl;
cout << "MPL Homework points entered:" << MPLHomework
<< endl;
cout << "Final Exam points entered:" << FinalExam
<< endl;
cout << "Total number of points earned:" << total
<< endl;
//Determining if the user input has an error and termination
return 0;
}
#include <iostream>
using namespace std;
int main()
{
const int possible = 1000;
const int ASSIGNMENT = 400;
const int HW = 200;
const int FINAL = 400;
int temp;
int Assignment;
int MPLHomework;
int FinalExam;
int Grade;
int Total;
//Stating the name of the program and what it does
cout << "Welcome to the Grade Calculator" <<
endl;
cout << "The following program will calculate your
grade\n";
cout << "In CSC205 by averaging three inputs such
as\n";
cout << "Your points from programming assignments, MPL
homework, and the final exam." << endl;
//Receiving user input
cout << "Please enter the amount of points for your
Programming Assignments:"<<endl;
cin >> Assignment;
cout << "Please enter the amount of points for your MPL
Homework:" <<endl;
cin >> MPLHomework;
cout << "Please enter the amount of points for your Final
Exam:" <<endl;
cin >> FinalExam;
//Total
Total = FinalExam + Assignment + MPLHomework;
//Input Checking
if (Assignment>=ASSIGNMENT||Assignment<=0)
{
cout<<"The number of points entered for Programming
Assignments must be between 0 and 400, inclusive.";
}
if(MPLHomework>=HW||MPLHomework<=0)
{
cout<<"The number of points entered for MPL Homework must be
between 0 and 200, inclusive.";
}
if(FinalExam>=FINAL||FinalExam <=0)
{
cout<<"The number of points entered for the Final Exam must
be between 0 and 400, inclusive.";
}
if(Assignment <= ASSIGNMENT && MPLHomework <= HW
&& FinalExam <= FINAL&&
Assignment>=0 && MPLHomework>=0 &&
FinalExam>=0)
{
cout << "Programming Assignment points entered:" <<
Assignment << endl;
cout << "MPL Homework points entered:" << MPLHomework
<< endl;
cout << "Final Exam points entered:" << FinalExam
<< endl;
cout << "Total number of points earned:" << Total
<< endl;
//Grade Assignment
if(Total>=900)
Grade=1;
else if(Total>=800)
Grade=2;
else if(Total>=700)
Grade=3;
else if(Total>=600)
Grade=4;
else
Grade=5;
if(FinalExam <= 240)
Grade=6;
//Output
switch(Grade)
{
case 1:cout<<"Student's letter grade earned: A\nGreat job!
You will have no problem in CSC205.\n";
break;
case 2:cout<<"Student's letter grade earned: B\nGood job! You
should have little trouble in CSC205.\n";
break;
case 3:cout<<"Student's letter grade earned: C\nOk, you
passed, but you may be challenged in CSC205.\n";
break;
case 4:cout<<"Student's letter grade earned: D\n When you
retake this course, you will be able to do much better.\n";
break;
case 5:break;
case 6:
{ cout<<"Student's letter grade earned: F\n";
if(FinalExam <= 240)
{
cout<<"You did not score enough points on the FinalExam to
pass this course."<<endl;
}
else
{
cout<<"You did not put forth enough effort to pass this
course.";
}
break;
}
}
}
//Determining if the user input has an error and termination
return 0;
}