Question

​Design and implement a program (name it Grade Report) that uses a switch statement to print out a message

Design and implement a program (name it Grade Report) that uses a switch statement to print out a message that reflect the student grade on a test. The messages are as follows 

image.png

3 0
Add a comment Improve this question Transcribed image text
Answer #1
using System;

class GradeReport {
    public static void Main (string[] args) {
        string userInput;//To take user input
        int grade;//To store grade
        Console.Write("You entered ");
        userInput = Console.ReadLine();//Input grade from the user
        grade = Convert.ToInt32(userInput);//Convert userInput to int
        grade = grade/10;//Divide grade by 10. So that if grade is between 90 and 99
                         //9 can be used in switch case for whole 90-99 range

        switch(grade){
            //For range 100 and above
            case 10:
                Console.WriteLine("That grade is a perfect score. Well done.");
                break;
            //For range 90 to 99
            case 9:
                Console.WriteLine("That grade is well above average. Excellent work.");
                break;
            //For range 80 to 89
            case 8:
                Console.WriteLine("That grade is above average. Nice job.");
                break;
            //For range 70 to 79
            case 7:
                Console.WriteLine("That grade is average work.");
                break;
            //For range 60 to 69
            case 6:
                Console.WriteLine("That grade is not good, you should seek help!");
                break;
            //For range below 60
            default:
                Console.WriteLine("That grade is not passing.");
                break;
        }
    }
}

OUTPUT:
main.csっsaved 1 using System; 2 3 class GradeReport ( 4 public static void Main (string[] args) ( Mono C# compiler version 4.0.4.0 You entered 85 That grade is above average. Nice job 6 7 8 9 10 string userInput int grade; Console.Write(You entered ); userInput -Console.ReadLine); grade = Convert . Toint32(userInput );//Convert userInput to int grade = grade/10; switch(grade) 12 13 14 case 18: Console.WriteLine(That grade is a perfect score. Well done.); break; 16 17 18 19 28 21 case 9: Console.WriteLine(That grade is well above average. Excellent work.); break; case 8: Console.WriteLine(That grade is above average. Nice job.); break; case 7:

Add a comment
Know the answer?
Add Answer to:
​Design and implement a program (name it Grade Report) that uses a switch statement to print out a message
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Favorites) to print out on...

    IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Favorites) to print out on separate lines the following: your name, your birthday, your hobbies, your favorite book, and your favorite movie.

  • SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes...

    SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array....

  • Find the errors in following program. //This program uses a switch statement to assign a //...

    Find the errors in following program. //This program uses a switch statement to assign a // letter grade (A, B, C, D, or F) to numeric test score. #include <iostream> uisng namespace std; int main() { int testScore; cout<<"Enter your test score and I will tell you\n"; cout<<"the letter grade you earned: "; cin>>testScore; switch (testScore) { case (testScore < 60) cout<<"Your grade is F.\n"; break; case (testScore <70) cout<<"Your grade is D.\n" break; case (testScore <80) cout<<"Your grade is...

  • Write a program that uses repetition and switch statements to print the song "The Twelve Days...

    Write a program that uses repetition and switch statements to print the song "The Twelve Days of Christmas." One switch statement should be used to print the day (i.e., "first," "second," etc.).A separate switch statement should be used to print the remainder of each verse.

  • This C# program prints out a corresponding letter grade for a given mark. It uses a...

    This C# program prints out a corresponding letter grade for a given mark. It uses a method (called MarktoGrade) to determine the letter grade. MarktoGrade takes one integer call by value formal parameter (called mark) and returns a char value that is the letter grade. All of the input and output (except an error message) is done in Main. There is one syntax error in this program that you will need to fix before it will compile (the error is...

  • PLEASE DO THIS IN C#.Design and implement a program (name it ProcessGrades) that reads from the...

    PLEASE DO THIS IN C#.Design and implement a program (name it ProcessGrades) that reads from the user four integer values between 0 and 100, representing grades. The program then, on separate lines, prints out the entered grades followed by the highest grade, lowest grade, and averages of all four grades. Format the outputs following the sample runs below. Sample run 1: You entered: 95, 80, 100, 70 Highest grade: 100 Lowest grade: 70 Average grade: 86.25

  • PLEASE DO THIS IN PYTHON!!! 1.) Exercise #1: Design and implement a program (name it Youth)...

    PLEASE DO THIS IN PYTHON!!! 1.) Exercise #1: Design and implement a program (name it Youth) that reads from the user an integer values repressing age (say, age). The program prints out the entered values followed by a message as follows: If age is less or equal to 21, the message is “Youth is a wonderful thing. Enjoy.”. Finally, the program always prints out the message “Age is a state of mind.” Format the outputs following the sample runs below....

  • Java program Program: Grade Stats In this program you will create a utility to calculate and...

    Java program Program: Grade Stats In this program you will create a utility to calculate and display various statistics about the grades of a class. In particular, you will read a CSV file (comma separated value) that stores the grades for a class, and then print out various statistics, either for the whole class, individual assignments, or individual students Things you will learn Robustly parsing simple text files Defining your own objects and using them in a program Handling multiple...

  • Write a Java program (name it SandClock) that uses nested loops to print out the following...

    Write a Java program (name it SandClock) that uses nested loops to print out the following shape (sand clock). * *** ***** ******* *********

  • Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the...

    Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the sum of the width and height is greater than 30 Method Area() returns the area of the rectangle if it is a valid rectangle Method Perimeter() returns the perimeter of the rectangle if it is a valid rectangle The main method of MyRectangle prompts the user to enter the width and height of a rectangle...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT