11/04/2015

Java Program For Find A Grade Of Given Marks Using Switch Case

Problem:- Java Program to Calculate Grade of Students or simple java program to print grades or Java program to finds percentage and grade of student entered by user or Java Program to Read a Grade & Display or java program to calculate grades or java program to enter grades or java program for a simple grading system or grade program in Java or Java Program For Find A Grade Of Given Marks Using Switch Case or C Program For Find A Grade Of Given Marks Using Switch Case or C++ Program For Find A Grade Of Given Marks Using Switch Case.

Check This:- HackerRank solution for C++ Domain.


Logic:- Logic is very simple for grade program in Java using a switch case. Taking an input from the user(Input should be between range given 0 to 100 Else program play with you), as we know that grading system so divides the Mark by 10 and put the case condition in program See the below Explanation Step by step for better understanding.

Explanation:- So first divide the mark by 10 so we can get a reminder and as you can see in the program we use case 4 to case 10. So if the remainder is between 4 to 10 our case perform the particular grade operation and display the result See the Step By Step Example for each case may be in this grade problem.

Example:-

Case 1:- If the user is Over smart then there is a condition that if the mark given by the user is greater than 100 then our program display the Message "Don't Be Smart Enter your Marks Between Limit" or else perform the Else part.

Enter the Mark:- 1000
Output:- Don't Be Smart Enter your Marks Between Limit.

Case 2:- If the user is entering the marks between the 0 to 100 and then particular grade portion will be executed and display the output in Console screen.

Enter the Mark:- 95
Output:-Your Grade Is: A or Excellent

This operation performs same for Grade B, C, D.

Case 3:- If Enter marks are not fulfilled the cases requirement than the program will perform the default case.

Enter the Mark:-25
Output:-You Grade Is: F or Fail

Also, see the program suggestion " Do Not show your Sheet to Your Parent "


Suggestion:- C Program For Find A Grade Of Given Marks Using Switch Case

Solution


import java.util.Scanner;
/* Program By Ghanendra Yadav
   Visit http://www.programmingwithbasics.com/
*/
class grade
{
   static Scanner sc = new Scanner(System.in);
   public static void main(String args[])
   {  

   int marks;
   
   /*This Is a Grade Checker Program*/
   while(true)
   {
   System.out.print("\n=========================================");
   System.out.print("\nThis Is a Grade Checker Program");
   System.out.print("\n-----------------------------------");
   System.out.print("\nEnter The Marks Between 0 To 100:");
   System.out.print("\n=========================================\n");
   
   System.out.print("\nEnter The Mark: ");
   marks = sc.nextInt();
   
   if(marks>100)
   {
    /* Marks greater than 100 */
    System.out.print("\nDon't Be Smart Enter your Marks Between Limit\n");
   }
   else
   {
   switch(marks/10)
   {
       case 10 :
       case 9 :
           /* Marks between 90-100 */
           System.out.print("\n=============================");
           System.out.print("\nYour Grade Is: A or Excellent");
           System.out.print("\n=============================");
           break;
       case 8 :
       case 7 :
           /* Marks between 70-89 */
           System.out.print("\n=============================");
           System.out.print("\nYour Grade Is: B or Very Good" );
           System.out.print("\n=============================");
           break;
       case 6 :
           /* Marks between 60-69 */
           System.out.print("\n========================");
           System.out.print("\nYour Grade Is: C or Fair" );
           System.out.print("\n========================");
           break;
       case 5 :
       case 4 :
           /* Marks between 40-59 */
           System.out.print("\n========================");
           System.out.print("\nYour Grade Is: D or Pass");
           System.out.print("\n========================");
           break;
       default :
           /* Marks less than 40 */
           System.out.print("\n================================================");
           System.out.print("\nYou Grade Is: F or Fail\n");
           System.out.print("\nSuggetin: Do Not show your Sheet to Your Parent");
           System.out.print("\n================================================");
   }
 }
}   
   }
}

Suggestion:- C++ Program For Find A Grade Of Given Marks Using Switch Case

Output:-

Java Program For Find A Grade Of Given Marks Using Switch Case

You May Like This


1. HackerRank Solution for 30 Days of Code

2. Java Program For Find The Gross Salary Of An Employee

3. C++ Program For School Management System ( SMS Project ) With Source Code

4. HackerRank Solution For Birthday Cake Candles

5. Java Program For Converting Temperature Celsius Into Fahrenheit
Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

1 comment: