Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Need help on c#

Ask the student to input their grade from their test


If the student got an A or a B grade then it should output “Well Done”


If the student gets a C grade it should output “Room for Improvement”


If the student got any other mark then it should say “ Try Harder”

Answers

  • I am new to C# and only got 4 Days of experience now but this is what i came up with. Im sure that there is a more effective way of setting grade to a lower case.

    using System;


    namespace ConsoleApp2

    {

      class Program

      {

        static void Main(string[] args)

        {

          Console.WriteLine("Pleas enter your grade: ");

          string grade = Convert.ToString(Console.ReadLine());

          grade = grade.ToLower();


          switch (grade)

          {

            case "a":

              Console.WriteLine("Very well Done");

              break;

            case "b":

              Console.WriteLine("Well Done");

              break;

            case "c":

              Console.WriteLine("Room for Improvement");

              break;         

            default:

              Console.WriteLine("Try Harder");

              break;

          }

           


          Console.ReadKey(true);

        }

      }

    }

  • Thanks mate this really helped.

Sign In or Register to comment.