Write a program to display result of student according to their marks using Switch case

 

AIM: Write a program to display the result of student according to their marks using Switch case

 

CODE:

import java.util.Scanner;

public class marks

{

            public static void main(String args[])

            {

                         Scanner readme = new Scanner(System.in);

                         System.out.println("Enter Number " );

                        int n1;

                        n1 = readme.nextInt();

                        System.out.println("\nYour Result is:\n");

                        switch(n1/10)

                        {

                                   

                                    case 10:

                                    case 9:

                                    case 8:

                                                   System.out.println("Congratulations You have passed with A+");

                                                   break;

                                    case 7:

                                    case 6:

                                                   System.out.println("Very good You have passed with A");

                                                   break;

                                    case 5:

                                                   System.out.println("Good You have passed with B+");

                                                   break;

                                    case 4:

                                                   System.out.println("You passed with C+");

                                                   break;

                                    case 3:

                                    case 2:

                                    case 1:

                                                   System.out.println("Sorry, You havn't passed the exam");

                                                   break;

                                    default:

                                                   System.out.println("Please enter no between 1 to 100");

                                   

                        }

            }

}

 

 

OUTPUT:





Comments

Popular posts from this blog

Write an application that illustrates method overriding in the same package and different packages. Also demonstrate accessibility rules in inside and outside packages

Describe abstract class called Shape which has three subclasses say Triangle, Rectangle, and Circle. Define one method area()in the abstract class and override this area() in these three subclasses to calculate for specific object.

Write a Java Program with class Rectangle having instance variable width, length, area and colour. Create methods like setData() and area().Create two object of Rectangle and compare their area and colour. If area and colour both are the same for the objects then display “Matching Rectangles”, otherwise display “Non matching Rectangle”.