Question

In: Computer Science

3. Write a program using switch-case statements that accepts an integer number between 0 and 100...

3. Write a program using switch-case statements that accepts an integer number between 0 and 100 and, based on its value, reports its equivalent letter grade (A, B, C, D, or F).

Solutions

Expert Solution

Since the Language to be coded was not mentioned, I have written it in C

#include<stdio.h>
 int main()
 {
     int marks;

     printf("Enter marks between 0 and 100: ");  //Asks for mark input
     scanf("%d",&marks);   //Stores in variable

     switch( score / 10 ) //Runs a switch case to check the grade
     {

     case 10:
     case 9:
         printf("Grade is : A\n"); //Prints the Grade in each case
         break;

     case 8:
         printf("Grade is: B\n");
         break;

     case 7:
         printf("Grade is: C\n");
         break;

     case 6:
         printf("Grade is: D\n");
         break;

     case 5:
         printf("Grade is: E\n");
         break;

     default:
         printf("Grade is: F\n");
         break;

     }

The criteria is given as

Please comment if any further explanation is needed


Related Solutions

Write a C++ program that accepts a positive integer number from the keyboard . The purpose...
Write a C++ program that accepts a positive integer number from the keyboard . The purpose of the program is to find and the display all the square pair numbers between 1 and that number. The user should be able to repeat the process until he/she enters n or N in order to terminate the process and the program. Square numbers are certain pairs of numbers when added together gives a square number and when subtracted also gives a square...
8. write a program using switch-case statements that ask a user to enter a temperature value...
8. write a program using switch-case statements that ask a user to enter a temperature value in degrees Fahrenheit (In your program, use an integer to record the user’s entry. If the temperature falls between 0 and 96 make it print “Temperature below normal”. If the temperature is 97, 98, make it “Temperature normal”. If the temperature is between 100 and 150, print “You have a fever”. If the temperature is outside the ranges given above, display “Are you human”....
C++ Write a program using switch-case-break that will take an input number as for example 2...
C++ Write a program using switch-case-break that will take an input number as for example 2 and based on switch it will provide various powers of 2.
Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0...
Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0 and 100). The program should store the numbers in an array and then display the following information: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Your program should consist of the following: Module main. Accepts input of numbers and assigns them to an array....
Write a program using switch statement that asks user to enter the month number and then...
Write a program using switch statement that asks user to enter the month number and then it prints out the number of days for that month. For simplicity reasons have your program print 28 days for February no matter if it is a leap year or not. Your program should also handle any invalid month numbers that user could enter (hint use default for the switch). Use a while loop to allow user to test for different month entries till...
Question 2. Write a MARIE program that accepts an integer from the user, and if it...
Question 2. Write a MARIE program that accepts an integer from the user, and if it is a prime number the program will output 1, otherwise, the program will output 0. Examples: If the user input is 17, the output would be 1 If the user input is 2, the output would be 1 If the user input is 15, the output would be 0 If the user input is -2, the output would be 0 You should write and...
Write a program which asks the user for grade, in integer form, from 0 to 100....
Write a program which asks the user for grade, in integer form, from 0 to 100. If the user's response is negative or greater than 100, insult them. Otherwise, use if / else statements to print out the letter grade corresponding to the user's input. 90 - 100 : A 80 - 89 : B 70 - 79 : C 60 - 69 : D 0 - 59 : F Then, write a second version of the program which uses...
Write a program which asks the user for grade, in integer form, from 0 to 100....
Write a program which asks the user for grade, in integer form, from 0 to 100. If the user's response is negative or greater than 100, insult them. Otherwise, use if / else statements to print out the letter grade corresponding to the user's input. 90 - 100 : A 80 - 89 : B 70 - 79 : C 60 - 69 : D 0 - 59 : F Then, write a second version of the program which uses...
Write a program to reverse each integer number on array (size 3) using while loop. C++...
Write a program to reverse each integer number on array (size 3) using while loop. C++ Input: 3678 2390 1783 Output: 8763 0932 3871
Write a C++ program that accepts a single integer value entered by user. If the value...
Write a C++ program that accepts a single integer value entered by user. If the value entered is less than one the program prints nothing. If the user enters a positive integer n. The program prints n x n box drawn with * characters. If the user enters 1 , for example the program prints *. If the user enter a 2, it prints ** ** that is , a 2x2 box of * symbols.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT