C++ Write a program that will ask the user for three test scores. These test sco
ID: 3863501 • Letter: C
Question
C++
Write a program that will ask the user for three test scores. These test scores are integers and vary from 0 to 100. Write the condition so that it uses 0 and 100 to determine if the score is not in range of 0 to 100. Do NOT use -1 and 101 or any other combination of values and do NOT use NOT (!) or else. The program should calculate the average of the three test scores and display the result as a floating point number rounded to the nearest tenth (one digit past the decimal point). Do not use the float data type.
The average test score should then be applied to the following table to determine a letter grade:
For integer data use int. For floating point data use double. Avoid using short, long, and long long for integer data unless you cannot use the int data type. Also, avoid using float or long double for floating point data unless you cannot use the double data type.
Test Score Average90 to 100
80 to 89
70 to 79
60 to 69
0 to 59 Letter Grade
A
B
C
D
F
Explanation / Answer
Program :
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() {
// your code goes here
int a,b,c;
cout << "Enter 3 test scores ";
cin >>a>>b>>c;
double avg = (a+b+c+0.00)/3;
cout<<"Average is "<< avg<<endl;
if(avg>=90&&avg<=100){
cout<<"A";
}
else if(avg>=80&&avg<=89){
cout<<"B";
}
else if(avg>=70&&avg<=79){
cout<<"C";
}
else if(avg>=60&&avg<=69){
cout<<"D";
}
else if(avg>=0&&avg<=59){
cout<<"F";
}
return 0;
}
OUPUT :
Enter 3 test scores
61
43
56
Average is 53.3333
F
OUTPUT :
Enter 3 test scores
79
85
92
Average is 85.3333
B
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.