Student mark list using nested if condition in Java


Here is the simple program for printing student marklist using if condition in Java.

Source Code

import java.io.*;
import java.util.Scanner;
//Tutor Joes Computer Education
class marklist
{
  public static void main(String args[])
  {
  int eng,mat,sci,soc,tam,to,av;
  Scanner in= new Scanner(System.in);
  System.out.println("\n Enter 5 Numbers:");
  eng=in.nextInt();
  mat=in.nextInt();
  sci=in.nextInt();
  soc=in.nextInt();
  tam=in.nextInt();
  to=eng+mat+sci+soc+tam;
  av=to/5;
  System.out.println("__________________________");
  System.out.println("English : "+eng);
  System.out.println("Maths   : "+mat);
  System.out.println("Science : "+sci);
  System.out.println("Social  : "+soc);
  System.out.println("Tamil   : "+tam);
  System.out.println("Total   : "+to);
  System.out.println("Average : "+av);
  if(eng>=35&&mat>=35&&sci>=35&&soc>=35&&tam>=35)
  {
    System.out.println("Result: All Pass ");
    if(av>=90&&av<=100)
    {
      System.out.println("Grade : A++ ");
    }
    else if(av>=70&&av<=89)
    {
      System.out.println("Grade : A");
    }
    else if(av>60&&av<=69)
    {
      System.out.println("Grade : B+");
    }
    else
    {
     System.out.println("Grade : C");
    }
  }
  else
  {
    System.out.println("Result: Fail ");
    System.out.println("Grade : Nil");
  }
  }
}
To download raw file Click Here

Output

Enter 5 Numbers:
89
78
98
78
86
__________________________
English : 89
Maths   : 78
Science : 98
Social  : 78
Tamil   : 86
Total   : 429
Average : 85
Result: All Pass
Grade : A


Learn All in Tamil © Designed & Developed By Tutor Joes