fix the error

// in Mr. Smith's mathematics class.
// Several errors have been made in the if statements.
// Eliminate the errors and compile and run.
//include files...
#include <iostream>

using namespace std;

int main()
{
//local declarations..
int classification; //classification of a student

// input student's information
cout << "Enter the student's classification (1 = freshman,"
<< endl;
cout << "2 = sophomore, etc.): ";
cin >> classification;
cout << "classification = " << classification ;
cout <<endl;

//check for a valid class and proceed accordingly
// classification 1 : freshman
// classification 2 : sophomore
// classification 3 : junior
// classification 4 : senior
// classification 5 : graduate
// classification is not above : "You entered an invalid class "

if (classification >= 1 && classification <= 5)
{
//display classification
cout << "Your classification is " ;
if (classification==1); // An error here
cout << "freshman";
else if(classification==2)
cout << "sophomore";
else if(classification==2) // An error here
cout << "junior";
else if(classification==2) // An error here
cout << "senior";
else
cout << "graduate";
cout << endl;
// An error here
else
cout << "You entered an invalid class " << endl;


//include files...
#include <iostream>
using namespace std;

int main()
{
//local declarations..

int test1, test2, test3; //three test scores
float average;
char grade;

// get the three test scores
cout << "Enter three test scores: ";
cin >> test1 >> test2 >> test3;
cout << "test1 = " << test1 << endl;
cout << "test2 = " << test2 << endl;
cout << "test3 = " << test3 << endl;
//find average and display pass/fail status
//calculate the average score
average = (test1 + test2 + test3)/3.0;
//print the student's letter grade
// A for >=90
// B for >=80
// C for >=70
// D for >=60
// F below 60


if (average >= 90)
grade = 'A';
if (average >= 80) // An error here
grade = 'B';
if (average >= 70) // An error here
grade = 'C';
if (average <= 60) [b]// Two errors here
grade = 'D';
else
grade = 'F';

cout <<"Your grade is " << grade << endl;

if ( grade = 'A') // An error here
cout <<"You are an excellent student" << endl;
Last edited on
Besides being in the wrong section (Should be in Beginners), this is so rude.

We don't do your homeworks.
Go study.
If you can't solve questions this simple, you are wasting your time studying.
Topic archived. No new replies allowed.