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

88: Using switch statement Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate percentage and grade according to following: // Percentage >= 90% : Grade A Percentage >= 80% : Grade B Percentage >= 70% : Grade C Percentage >= 60% : Grade D Percentage >= 40% : Grade E Percentage < 40% : Grade F

205: Book Catalog: Define a struct to represent a book with attributes like title, author, and publication year. Write a program to create a catalog of books by taking user input and display books published after a certain year.

15: Take input of age and name of 3 people by user and determine oldest and youngest among them with his age. -_-_-_-_-_-_-_-_-(line with spaces input concept)-_-_-_-_-_-_-_-_