Please help me write this code in C++! Write a program that determines a student
ID: 3668916 • Letter: P
Question
Please help me write this code in C++!
Write a program that determines a student's letter grade. Allow the user to enter three test scores. The maximum score on each test is 100 points. Determine the letter grade from the average of the test scores, using the following: 90% or more A 80% or more, but less than 90% B 70% or more, but less than 80% C 60% or more, but less than 70% D or F, to be determined from additional information less than 60% F Only if the grade needs to be determined between D and F, allow the user to enter the number of homework assignments the student turned in, and the total number of homework assignments. If more than 80% of the homework assignments were turned in, the letter grade is D, otherwise F.
Test it 4 times: 96 84 90
95 83 90
70 59 60 with 5 homework out of 6 turned in
73 58 65 with 8 homework out of 11 turned in
Explanation / Answer
#include <iostream>
using namespace std;
int main() {
int m1,m2,m3;
float avg;
char grade;
int n1,n2;
cout<<"Enter 3 test scores";
cin>>m1>>m2>>m3;
avg = (m1+m2+m3)/3;
if(avg >= 90)
grade = 'A';
else if (avg >= 80)
grade = 'B';
else if (avg >= 70)
grade = 'C';
else if (avg >= 60){
cout<<" Enter the number of homework assignments turned in";
cin>>n1;
cout<<" Total number of homework assignments";
cin>>n2;
if(n1*100.0/n2 > 80)
grade = 'D';
else
grade = 'F';
}
else
grade = 'F';
cout<<" The grade awarded is : "<<grade;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.