Write a program that will allow a student to compute for his equivalent semestral grade.
The program should ask the user should input his/her first name, last name, middle initial, and student number.
After, inputting everything above, the output will clear the current screen and a new screen should open. On the new screen, the user will then be greeted "Welcome, <firstname>! The program will then ask for the prelim grade, midterm grade and final grade of the student. The program should only accept grades 100 and below. After getting the three grades, the program should compute for the semestral grade. The computation of the semestral grade is as follows: 30%*PrelimGrade + 30%*midtermgrade + 40%finalgrade
After inputting all the grades, the screen should clear again and will proceed to another screen.
Remarks should be "Passed" or "Failed" Only.
Hint You may use the relational operators "AND(&&)" and "OR(||)" for your conditions.
#include <iostream>
#include <string>
using namespace std;
struct Student
{
string firstname;
string lastname;
string midinitial;
int number;
};
int main()
{
Student s;
cout << "Please, enter your first name: ";
cin>>s.firstname;
cout << "Please, enter your last name: ";
cin >> s.lastname;
cout << "Please, enter your middle initial: ";
cin >> s.midinitial;
cout << "Please, enter your number: ";
cin >> s.number;
system("cls");
cout << "Welcome " << s.firstname << "!" << endl;
float prelimGrd, midGrd, finGrd;
cout << "\nPlease, enter your prelim grade: ";
cin >> prelimGrd;
cout << "\nPlease, enter your midterm grade: ";
cin >> midGrd;
cout << "\nPlease, enter your final grade: ";
cin >> finGrd;
system("cls");
if (prelimGrd > 100|| midGrd>100||finGrd>100)
{
cout << "Error entering! Your grades must be 100 or below!";
}
else
{
float semGrd = 0.3*prelimGrd + 0.3*midGrd + 0.4*finGrd;
if (semGrd >= 70)
cout << "Passed!";
else
cout << "Failed!";
}
}
Comments
Leave a comment