6. Due to poor results of your prelim examination, your teacher decides to increase each student’s grade by 5. Get all the grades and compute for the new grade. If the original grade exceeds 90, the grade remains as such. (grade.cpp)
Requirements:
Function for the input.
Function for the formula/process together with the output.
Sample Run:
Name: Eugerico
Grade: 80
Your new grade is 85
Do you want to enter another record [y/n]? y
Name: Laurence
Grade: 91
Your grade is still 91.
Do you want to enter another record [y/n]? y
Name: Ana
Grade: 76
Your new grade is 81
Do you want to enter another record [y/n]? n
Exit
1
Expert's answer
2013-02-28T09:23:58-0500
#include <iostream>
using namespace std;
int input_grade() { string name; int grade;
cout << "Name: "; cin >> name;
cout << "Grade: "; cin >> grade; return grade; }
void new_grade(int grade) { if (grade > 90) cout << "Your grade is still " << grade << "." << endl; else cout << "Your new grade is " << grade + 5 << "." << endl; }
int main() { char choice; do { new_grade(input_grade()); cout << "Do you want to enter another record [y/n]? "; cin >> choice; cout << endl; } while (choice == 'y');
Comments
Leave a comment