Console Application-Use of Select case

 
public void Main()

{

        int s1 = 0;

        int s2 = 0;

        int s3 = 0;

        int tot = 0;

        double per = 0;

        Console.WriteLine("Enter the mark of First Subject out of 100");

        s1 = Console.ReadLine();

        Console.WriteLine("Enter the mark of Second Subject out of 100");

        s2 = Console.ReadLine();

        Console.WriteLine("Enter the mark of Third Subject out of 100");

        s3 = Console.ReadLine();

        tot = s1 + s2 + s3;

        per = (tot / 300) * 100;

        Console.WriteLine("Your Total is:=>" + tot);

        Console.WriteLine("your Percentage is:=>" + per);

 

        switch ((per)) {

               case  // ERROR: Case labels with binary operators are unsupported : LessThan

40:

                       Console.WriteLine("Grade:=>Fail");

                       Console.ReadLine();

                       break;

               case 40:

               case 41:

               case 42:

               case 43:

               case 44:

               case 45:

               case 46:

               case 47:

               case 48:

               case 49:

               case 50:

                       Console.WriteLine("Grade:=>Second Class");

                       Console.ReadLine();

                       break;

               case 50:

               case 51:

               case 52:

               case 53:

               case 54:

               case 55:

               case 56:

               case 57:

               case 58:

               case 59:

               case 60:

                       Console.WriteLine("Grade:=>First Class");

                       Console.ReadLine();

                       break;

               case  // ERROR: Case labels with binary operators are unsupported : GreaterThan

70:

                       Console.WriteLine("Grade:=>Distionction");

                       Console.ReadLine();

                       break;

        }

}
Ebook Download
View all
Learn
View all