67 245
Assignments Done
99,2%
Successfully Done
In November 2018

Answer to Question #58959 in C++ for hussam

Question #58959
The output should be like this
Name ID First Second Final Sum Grade
Ali 20071156 15.5 16.5 30.1 62.1 D
how i can do like this porogram
Expert's answer
#include <iostream>
#include <string>

using namespace std;

struct Student{
string name;
int id;
double first;
double second;
double finalScore;
double sum;
char grad;

Student() {

}

Student(string name, int id, double first, double second, double finalScore) {
this->name = name;
this->id = id;
this->first = first;
this->second = second;
this->finalScore = finalScore;
sum = first + second + finalScore;
if (grad >= 90) {
grad = 'A';
}
else {
if (grad >= 80) {
grad = 'B';
}
else {
if (grad >= 65) {
grad = 'C';
}
else {
if (grad >= 55) {
grad = 'D';
}
else {
if (grad >= 50) {
grad = 'E';
}
else {
if (grad >= 35) {
grad = 'X';
}
else {
grad = 'F';
}
}
}
}
}
}
}
};

int main(void) {
Student student = Student("Ali", 20071156, 15.5, 16.5, 30.1);
cout << "Name\t" << "ID\t\t" << "First\t" << "Second\t" << "Final\t" << "Sum\t" << "Grade" << endl;
cout << student.name << '\t' << student.id << '\t' << student.first << '\t' << student.second << '\t' << student.finalScore << '\t' << student.sum << '\t' << student.grad << endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions