Step 1 (2 pts). Read from input student status (string), homework points, quiz points, midterm exam score, and final exam score (double). Valid student status includes undergrad (UG), grad (G), and distance leaner (DL). Calculate each category average using maximum points for homework (800), quizzes (400), midterm exam (150), and final exam (200). Output an error message if student status is not one of the three options. Otherwise, output category averages as a percentage using cout << "Homework: " << homework << "%" << endl;. Submit for grading to confirm two tests pass.
input is UG 600.0 300.0 120.0 185.0
#include <iostream>
#include <string>
using namespace std;
int main() {
//Read from input student status (string),
string status;
double homeworkPoints;
double quizPoints;
double midtermExamScore;
double finalExamScore;
double homework;
//Valid student status includes undergrad (UG), grad (G),
//and distance leaner (DL).
cout<<"Enter status (UG,G or DL): ";
getline(cin,status);
if(status.compare("UG")==0 || status.compare("G")==0 || status.compare("DL")==0){
cout<<"Enter homework points: ";
cin>>homeworkPoints;
cout<<"Enter quiz points: ";
cin>>quizPoints;
cout<<"Enter midterm exam score: ";
cin>>midtermExamScore;
cout<<"Enter final exam score: ";
cin>>finalExamScore;
//Calculate each category average
//using maximum points for homework (800), quizzes (400), 00
//midterm exam (150), and final exam (200).
homework=(homeworkPoints*100.0/800.0+quizPoints*100.0/400.0+midtermExamScore*100.0/150.0+finalExamScore*100.0/200.0)/4;
//Output an error message if student status is not
//one of the three options. Otherwise, output category averages as
//a percentage using cout << "Homework: " << homework << "%" << endl;.
cout << "Homework: " << homework << "%" << endl;
}else{
cout<<"Wrong status\n\n";
}
system("pause");
return 0;
}
Comments
Leave a comment