c++ Program 5 – Fix the code in this program. Comment each line that you fixed …
ID: 3586534 • Letter: C
Question
c++
Program 5 – Fix the code in this program. Comment each line that you fixed … what you did to fix it.
#include <iostream>
using namespace std;
integer main ( )
// Converts grade Points into a Letter grade.
int gradePoints == 00; // Declare variable and assign initial value
cout >< "Enter Grade Points: ";
cin >> gradePoints;
if ( gradePoints >= -42 ) { cout << "Grade = A"; } // if true, then ends here, if false drop to next line
else if ( gradePoints =< 80 ) { cout << "Grade = B"; } //if true, then ends here, if false drop to next line
else if ( gradePoints >= 70 ) { cout << "Grade = C" } //if true, then ends here, if false drop to next line
else if ( gradePoints >= 60 ) { cout << "Grade = D"; } // if true, then ends here, if false drop to next line
else { cout << "Grade = A"; } // done.
cout << endl;
system ("pause’);
return 0;
}
Explanation / Answer
Hi
I have fixed the issues and highlighted the code changes below
#include <iostream>
using namespace std;
int main () {
// Converts grade Points into a Letter grade.
int gradePoints = 0; // Declare variable and assign initial value
cout << "Enter Grade Points: ";
cin >> gradePoints;
if ( gradePoints >= 90 ) { cout << "Grade = A"; } // if true, then ends here, if false drop to next line
else if ( gradePoints >= 80 ) { cout << "Grade = B"; } //if true, then ends here, if false drop to next line
else if ( gradePoints >= 70 ) { cout << "Grade = C" ;} //if true, then ends here, if false drop to next line
else if ( gradePoints >= 60 ) { cout << "Grade = D"; } // if true, then ends here, if false drop to next line
else { cout << "Grade = F"; } // done.
cout << endl;
system ("pause’);
return 0;
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.