Question

In: Computer Science

Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this...

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:

  1. The number of points entered for Programming Assignments must be between 0 and 400, inclusive.
  2. The number of points entered for MPL Homework must be between 0 and 200, inclusive.
  3. The number of points entered for the Final Exam must be between 0 and 400, inclusive.

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:

  1. The number of Programming Assignment points entered
  2. The number of MPL Homework points entered
  3. The number of Final Exam points entered
  4. The total number of points earned
  5. The student's letter grade
  6. A support message based on the letter grade earned

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:

  1. For an A, print:      Great job! You will have no problem in CSC205.
  2. For a B, print:        Good job! You should have little trouble in CSC205.
  3. For a C, print:        Ok, you passed, but you may be challenged in CSC205.
  4. For a D, print:       When you retake this course, you will be able to do much better.
  5. For an F, print either:
              You did not put forth enough effort to pass this course.
    or
              You did not score enough points on the Final Exam to pass this course.

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;
}

Solutions

Expert Solution

#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;
}


Related Solutions

Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
Write a program that translates a letter grade into a number grade. Letter grades are A,...
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts Enter a Letter grade: B- The numeric value is 2.7 Your code with comments A screenshot...
Create the pseudocode solution to a program that calculates the final score and letter grade for...
Create the pseudocode solution to a program that calculates the final score and letter grade for one student. Please use the following grading system: 9 Homework Assignments – 100 points each 10 points 11 Quizzes – 100 points each 5 points 5 Projects – 100 points each 10 points 6 Discussion posts – 100 points each 10 points 4 Exams – 100 points each 65 points A = 90 – 100% B = 80 – 89% C = 70 –...
Write a C program that calculates the average grade for a specified number of students from...
Write a C program that calculates the average grade for a specified number of students from each student's test1 and test2 grades. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the test1 grade (grade #1) and test2 grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (test1 and test2). Use a two-dimensional float array to store...
Write a C program that calculates the average grade for a specified number of students from...
Write a C program that calculates the average grade for a specified number of students from each student's termtest and final grade. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the termtest grade (grade #1) and final grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (termtest and final). Use a two dimensional float array to...
Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade...
Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade point average (GPA) Each A is worth 4 points. Each B is worth 3 points. Each C is worth 2 points. Each D is worth 1 point, and Each F is worth 0 points. The total quality points earned is the sum of the product of letter grade points and associated course credit hours. The GPA is the quotient of the quality points divided...
USING C++ PLEASE Write a program named Lab11C that calculates the average of a group of...
USING C++ PLEASE Write a program named Lab11C that calculates the average of a group of test scores where the lowest score is dropped. It should use the following functions a) void getScores should have 4 double reference parameters (one for each test score) getScores should do the following: - read 4 test scores from the text file Lab11C.txt (Important: declare your ifstream infile and open the file inside this function, not in the main function) - store them in...
Question: How do I write a program in C# that calculates a student's final grade for...
Question: How do I write a program in C# that calculates a student's final grade for a test with 20 multiple questions using arrays and helper methods? Instructions: (0-incorrect answer, 1-correct answer) If the student answered the question right, add .5 points to the running total. If the student didn’t answer correctly subtract .5 points from the running total. The running total is initialized with 5 points (so the student receives 5 points extra credit). To define the final grade...
Write a C program that prints the Grade of each student in a class based on...
Write a C program that prints the Grade of each student in a class based on their mark. The program must also print the average mark of the class. The program must prompt (ask) the user for the mark of a student (out of 100). The program must then print the mark entered and the grade received based on the table below. Grade Range A 85 to 100 inclusive B 75 to 85 inclusive C 60 to 70 inclusive D...
write a Java program Write a program to assign a letter grade according to the following...
write a Java program Write a program to assign a letter grade according to the following scheme: A: total score >= 90 B: 80 <= total score < 90 C: 70 <= total score < 80 D: 60 <= total score < 70 F: total score < 60 Output - the student's total score (float, 2 decimals) and letter grade Testing - test your program with the following input data: test1 = 95; test2 = 80; final = 90; assignments...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT