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

215: Create a C++ program that uses single inheritance to model a simple shape hierarchy. Implement a base class "Shape" with a virtual function "printArea." Derive classes "Rectangle" and "Triangle" from "Shape" and override the "printArea" function to calculate and display their respective areas.

42: ***(Syntax)*** Calculating number of characters and spaces in a string 1- Make a program to calculate the number of characters in a string 2- Modify this and also tell how many spaces are there in that sentence

212: Build a class representing a university student with private data members for name, ID, and a static data member for the total number of students. Implement getter and setter functions for name and ID, and a static getter function to retrieve the total number of students. Use default constructors