14: The School has following rules for grading system: a. Below 25 - F, b. 25 to 45 - E, c. 46 to 50 - D, d. 51 to 60 - C, e. 61 to 80 - B, f. Above 80 - A. Ask user to enter marks and print the corresponding grade.

     


// The School has following rules for grading system:
// a. Below 25 - F
// b. 25 to 45 - E
// c. 46 to 50 - D
// d. 51 to 60 - C
// e. 61 to 80 - B
// f. Above 80 - A
// Ask user to enter marks and print the corresponding grade.


#include <iostream>
using namespace std;

int main(){

        float total_marks, obtained_marks, percentage;

        cout << "Enter obtained marks: ";
        cin >> obtained_marks;

        cout << "Enter total marks: ";
        cin >> total_marks;
       
        percentage = (obtained_marks / total_marks) * 100;

            if(percentage < 25){
                cout << "Your grade is: 'F'" << endl << "\nBetter luck next time\n";
            }

            else if(percentage >= 25 && percentage <= 45){
                cout << "Your grade is: 'E'" << endl << "\nYou need to work harder\n";
            }

            else if(percentage > 45 && percentage <= 50){
                cout << "Your grade is: 'D'" << endl << "\nYou need to work harder\n";
            }

            else if(percentage > 50 && percentage <= 60){
                cout << "Your grade is: 'C'" << endl << "\nYou need to work harder\n";
            }

            else if(percentage > 60 && percentage <= 80){
                cout << "Your grade is: 'B'" << endl << "\nNeed a bit more hard work\n";
            }

            else if(percentage > 80){
                cout << "Your grade is: 'A'" << endl << "\nWell done. Keep it up\n";
            }

    return 0;
}

Input 1:


Enter obtained marks: 210 Enter total marks: 1100

Output 1:


Your grade is: 'F' Better luck next time

Input 2:


Enter obtained marks: 350 Enter total marks: 1100

Output 2:


Your grade is: 'E'

You need to work harder

 

Input 3:


Enter obtained marks: 550 Enter total marks: 1100

Output 3:


Your grade is: 'D'

You need to work harder


Input 4:


Enter obtained marks: 600 Enter total marks: 1100

Output 4:


Your grade is: 'C'

You need to work harder


Input 5:


Enter obtained marks: 800 Enter total marks: 1100

Output 5:


Your grade is: 'B'
Need a bit more hard work

Input 6:


Enter obtained marks: 990 Enter total marks: 1100

Output 6:


Your grade is: 'A' Well done. Keep it up


Comments

Popular posts from this blog

153: Write a program to read an amount (integer value) and break the amount into smallest possible number of bank notes. Note: The possible banknotes are 500, 100, 50, 20, 10, 5, 2, and 1

206: Write a program to create a class named "Circle" which has the property "radius". Define functions to calculate the area and circumference of the circle.

221: // In Task 2, we discussed multilevel inheritance with parameterized constructors for Student, UndergraduateStudent, and GraduateStudent classes in a university management system. Can you explain the advantages of using multilevel inheritance with specific details about the functions and data members in these classes? How were the parameterized constructors (e.g., setting student name, age, and ID) used to ensure that each class in the hierarchy correctly initializes its properties, such as creating an UndergraduateStudent named "John," aged 20, with a student ID of 12345