Answer on Question #48928, Programming, C++
Task
Write a program that can enter marks for 1 student and calculate his total and grade with the following format
The inputs:
ID (As Integer), First (As Double), Second (As Double), Final (As Double), Total (As Double) and Grad (As Char)
The Grades are: A for 90's, B for 80's, C for 70's, D for 60's and F for less than 60.
The output:
Solution
#include <iostream>
using namespace std;
int main() {
int id;
double first, second, final, total;
char grade;
cout << "\nEnter the information about student:\n";
cout << "ID:";
cin >> id;
cout << "First:";
cin >> first;
cout << "Second:";
cin >> second;
cout << "Final:";
cin >> final;
total = first + second + final;
if (total >= 90) grade = 'A';
else if (total >= 80) grade = 'B';
else if (total >= 70) grade = 'C';
else if (total >= 60) grade = 'D';
else grade = 'F';
cout << "\nSt_Nm\tID\tFirst\tSecond\tFinal\tAverage\tGrade\n";
cout << id << "\t" << id << "\t" << first << "\t" << second << "\t" << final << "\t" << total << "\t" << grade;
cout << "\nFor exit enter any symbol\n";
cin >> id;
return 0;
}
Comments