Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Output1 Output 2 5. Write a C++ program named Lab8.cpp to calculate the average

ID: 3681063 • Letter: O

Question

Output1 Output 2 5. Write a C++ program named Lab8.cpp to calculate the average score of students for the Midterm Exam. Your program will repeatedly ask user to input a score for a student until user press "O" or “g" to quit. Define a function calcu lateAverage ( ) with the following header: double calculateAverage(vector scores)i The calculateAverage() function should take only valid scores in the range of [0, 100]. If the scores are out of range throw an OutOfRange exception; if the size of the vector is 0 (it represents that user does not input any valid score before clicking to quit), throw a DivideByZero exception. Define each of these two types of exceptions as a class similar to the one shown in Lab8_2.cpp. Write the comments for this function, specifying the pre conditions, post conditions and invariants and what exceptions are thrown so that the caller understands how it behaves. Compile and run your program with different cases, and test if your program catches the two types of exceptions.

Explanation / Answer


#include <iostream>
using namespace std;

int main()
{

char name [100];
char quit;
quit ='';
while (quit !='q')
{

system("Course Grade Calculation");
system("color 80");
int a, b, c, d, f, x, z; //loads integers into memory


cout <<"This is a Final Grade Calculator Program. Just input your 5 most highest grade when asked" << endl;
cout <<"Please enter your name?"<< endl;
cin.getline (name,100);
cout <<"Hello," << name << "."<< endl;
cout <<"Input your first grade:"<< endl;
cin>> a; //Receives grade and loads it into memory

cout <<"Input your second grade:"<< endl;
cin>> b;

cout<<"Input your fourth grade:"<< endl;
cin>> d;

cout<<"Finally, enter your last grade:"<< endl;
cin>> f;

z = a+b+c+d+f; //(starting division equation)
x = z; //makes the x integer equal to z

if (x/5<=65)
{
cout <<"Are you even trying to pass your class!?" << endl;
}
else if (x/5==75)
{
cout<<"Try to pick up the pace a bit more."<< endl;
}
else if (x/5==80)
{
cout<<"You are doing a great job with keeping your grades up."<< endl;
}
else if (x/5==90)
{

cout<<"You're doing an awesome job!"<< endl;
}
else if (x/5>=95)
{
cout<<"Teachers pet; I see!"<< endl;
}
cout<<"Your average is " << x/5 << "."<< endl; //(all grades/5)
cout<<""<< endl;
cout<<"Q - Quit"<< endl;
cout<<"R - Repeat"<< endl;
cout<<"Please type in the letter for your choice then press enter." << endl;
cin>> quit;
cout << "Goodbye," << name << "." << endl;


system("PAUSE");
system("cls");

}
return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote