Write a C++ program that computes student grades for an assignment as a percenta
ID: 3542450 • Letter: W
Question
Write a C++ program that computes student grades for an assignment as a percentage given each student's score and the total points. You should also display the floating-point results up to 2 decimal places. Get input data from Keyboard containing multiple lines with student's name, score, and total separated by a space. In addition, you should print to the console "Excellent" if the grade is greater than 90, "Well Done" if the grade is great than 80, "Good" if the grade is greater than 70, "Need Improvement: if the grade is greater than or equal to 60, and "Fail" if the grade is less than 50.
Here is an example of what the input file might look like:
Weems 50 60
Dale 51 60
Richards 57 60
Smith 36 60
Tomlin 44 60
Bird 45 60
The output of your program should look like this:
Weems .83 Well Done
Dale .85 Well Done
RIchards .95 Excellent
Smith .60 Need Improvement
Tomlin .73 Good
Bird .75 Good
*Can either use a For Loop or While Loop
*10 line data. (Keep simple)
* use <string> <iomanip>
* DO NOT USE <cmath>
Any help appreciated! I am new to this Chegg website. I have started on this assignment and it is not looking pretty. This is my first programming class and I am a bit confused. I do have some of the work done, but by Microsoft Visual C++ program is coming up with a lot of syntax errors. Again, I am a beginner to this C++
Explanation / Answer
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
string name[10];
double test1[10],test2[10];
double average[10];
for(int i=0; i<6; i++)
{
cout << "Enter student " << (i+1) << " data ";
cin >> name[i] >> test1[i] >> test2[i];
cout << endl;
average[i] = (test1[i]+test2[i])/132.0;
}
for(int i=0; i<6; i++)
{
cout << name[i] << " " << fixed << setprecision(2) << average[i] << " ";
if(average[i] > 0.90)
cout << " Excellent " << endl;
if(average[i] > 0.80)
cout << " Well Done " << endl;
else if(average[i] > 0.70)
cout << " Good " << endl;
else if(average[i] > 0.60)
cout << " Need Improvement " << endl;
}
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.