C++ Basic Program Logic As with program 1, prompt the user for the program avera
ID: 3883817 • Letter: C
Question
C++
Basic Program Logic
As with program 1, prompt the user for the program average and save that value in a double/float variable.
To calculate the test average, the user will be asked to enter 5 pieces of information. This means that 5 variables will need to be added to the program. The user should be asked for:
the sum of the user's test scores (double or float)
the maximum test points available (double or float)
the number of quizzes that the user has taken (integer)
the sum of all of the user's quiz scores (integer)
the sum of the user's two lowest quiz scores (integer)
After all the information has been entered, use the new information to calculate the user's test average as follows (NOTE: the formula is long. Make sure you're getting the entire formula):
Note: For this assignment, it is safe to assume that the maximum test points available will not be 0 and that the user has taken more than 2 quizzes.
Use the program average and calculated test average to calculate the course average for the user. The formula is the same as in program 1.
As with program 1, display the program average, test average, and course average. However, for this assignment, all of the averages MUST be displayed with exactly 2 digits after the decimal point.
Program Requirements
the averages should all be displayed with exactly 2 digits after the decimal point.
The program average, sum of the user's test scores, maximum test points available, calculated test average, and calculated course average should be type float or double. The number of quizzes, sum of all of the user's quiz scores, and sum of the user's two lowest quiz scores should be type integer. Make sure to use meaningful variable names.
Make sure and test your program with values that you have calculated.
Hand in a copy of your source code using Blackboard.
Output
A few runs of the program should produce the following results:
Run 1
Run 2
Run 3
Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double programAverage, sumTestScores, maxTestPoints;
int numOfPuzzels, sumOfQuzzies, sumOfLowestQuiz;
cout<<"Enter the program average: ";
cin >> programAverage;
cout<<"Enter the sum of the test scores: ";
cin >> sumTestScores;
cout<<"Enter the maximum test points available: ";
cin >> maxTestPoints;
cout<<"Enter the number of quizzes that have been taken: ";
cin >> numOfPuzzels;
cout<<"Enter the sum of all of the quizzes that have been taken: ";
cin >> sumOfQuzzies;
cout<<"Enter the sum of the two lowest quiz scores: ";
cin >> sumOfLowestQuiz;
double testAverage = (sumTestScores + sumOfQuzzies - sumOfLowestQuiz) / (maxTestPoints + (10 * (numOfPuzzels - 2))) * 100;
cout<<endl;
cout<<endl<<"***********************"<<endl;
cout<<"Grade Calculator"<<endl<<endl;
cout<<fixed<<setprecision(2)<<"Program Average: "<<programAverage<<endl;
cout<<fixed<<setprecision(2)<<"Test Average: "<<testAverage<<endl;
cout<<endl;
cout<<fixed<<setprecision(2)<<"Course Average:"<<(testAverage+programAverage)/2<<endl;
return 0;
}
Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.