Okay, so the textbook solution is wrong on here. I need help on this. It should
ID: 672745 • Letter: O
Question
Okay, so the textbook solution is wrong on here. I need help on this. It should look like the picture below. This is a Visual Studio assignment. This was answered yesterday but not as a Visual Studio assignment.
Average Test Score
Letter Grade
90 or greater
A
80 through 89
B
70 through 79
C
60 through 69
D
Below 60
F
The application should prompt the user for each student’s name and three test scores.
Average Test Score
Letter Grade
90 or greater
A
80 through 89
B
70 through 79
C
60 through 69
D
Below 60
F
Explanation / Answer
// ConsoleApplication8.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include<string>
#include <cstdlib>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string name;
double marks[3];
double avg=0;
char grade;
int n=1;
while(n==1){
cout << "Enter name of student: ";
cin >> name;
for(int i=0;i<3;i++){
cout<<"Enter marks of "<<(i+1)<<" subject: ";
cin>>marks[i];
avg=avg+marks[i];
}
avg=avg/3;
if(avg>=90){
grade='A';
}else if(avg>=80){
grade='B';
}else if(avg>=70){
grade='C';
}else if(avg>=60){
grade='D';
}else{
grade='F';
}
cout<<"average: "<<avg<<" grade: "<<grade<<endl;
avg=0;
cout<<"1 to continue anything else to quit";
cin>>n;
}
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.