Your English instructor, realizing you are a programmer, asks you to write a Gra
ID: 672680 • Letter: Y
Question
Your English instructor, realizing you are a programmer, asks you to write a Grade Book program for his class to help him compute final grades. Design a program that asks for the student’s name and four test grades. You are to display the student’s name, four test grades, the average of the four test grades and the final letter grade the student earned in the course.
Your English instructor gives you the following grading scale:
Submit your C++ source code that you generated from RAPTOR with comments added to each line or where necessary to explain program flow. Also submit the RAPTOR file (flowchart) of your working program.
95-100 A+ 90-94 A- 85-89 B+ 80-84 B- 75-79 C+ 70-74 C- 65-69 D+ 60-64 D- 59 or below FExplanation / Answer
#include <iostream>
#include<string>
using namespace std;
struct student {
string name;
int scores[4];
float avg;
string grade;
} st;
int main() {
int sum=0;
cout<<"Enter name: ";
cin>>st.name;
cout<<" Enter all 4 scores: ";
for(int i=0; i<4; i++) {
cin>>st.scores[i];
sum += st.scores[i];
}
st.avg = sum/4.0;
if(st.avg >= 95)
st.grade = "A+";
else if(st.avg >= 90 && st.avg <= 94)
st.grade = "A-";
else if(st.avg >= 85 && st.avg <= 89)
st.grade = "B+";
else if(st.avg >= 80 && st.avg <= 84)
st.grade = "B-";
else if(st.avg >= 75 && st.avg <= 79)
st.grade = "C+";
else if(st.avg >= 70 && st.avg <= 74)
st.grade = "C-";
else if(st.avg >= 65 && st.avg <= 69)
st.grade = "D+";
else if(st.avg >= 60 && st.avg <= 64)
st.grade = "D-";
else
st.grade = "F";
cout<<" ";
cout<<"Students name: "<<st.name;
cout<<" Scores: "<<st.scores[0]<<","<<st.scores[1]<<","<<st.scores[2]<<","<<st.scores[3]<<" ";
cout<<"Average: "<<st.avg<<" ";
cout<<"Grade: "<<st.grade<<" ";
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.