![]() |
VOOZH | about |
Write a Menu-driven program to check Whether a student passes/fails using his/her grade.
Condition to pass: Grade should be greater than or equal to 33.
Valid grade range: 0 to 100
A menu-driven program is a type of computer program that allows users to interact with it by selecting options from a menu. Instead of typing commands or code, users navigate through a series of menus that present a list of actions or functions they can perform.
Examples:
Enter students grade: 150
Invalid grades
To continue press Y
Press any other key to exit
Y
Enter students grade: -509
Invalid grades
To continue press Y
Press any other key to exit
Y
Enter students grade: 45
Pass
To continue press Y
Press any other key to exit
Y
Enter students grade: 12
Fail
To continue press Y
Press any other key to exit
N
Program Terminated
Approach: To solve the problem, follow the below idea:
The problem can be solved using a while loop which keeps on asking the user to input the grade. Inside the while loop, the user enters the grade and if the grade < 33, the user fails else the user passes. After every result, the user is prompted if he wants to continue entering the grades or exit the program. The program exits if the user inputs anything except "Y".
Below is the implementation of the approach:
Output:
Enter students grade: 150
Invalid grades
To continue press Y
Press any other key to exit
Y
Enter students grade: -509
Invalid grades
To continue press Y
Press any other key to exit
Y
Enter students grade: 45
Pass
To continue press Y
Press any other key to exit
Y
Enter students grade: 12
Fail
To continue press Y
Press any other key to exit
N
Program Terminated