OneCompiler

TO FIND THE PERCENTAGE OF THE STUDENT

245

WRITE A PRGRAM TO FIND THE PERCENTAGE OF A STUDENT BY ACCEPTING THE MARKS OF THE STUDENT IN 4 SUBJECTS [CHEMISTRY , MATHS , PHYSICS , COMPUTER ]

import java .util.; //or import java . util.Scanner;
class percentage
{
public static void main(String[]args)
{
Scanner sc = new Scanner(System.in);
System.out.println("ENTER MARKS IN FOUR SUBJECTS : ");
System.out.print("PHYSICS : ");
int phy = sc.nextInt();
System.out.println("");
System.out.print("CHEMISTRY");
int chem = sc.nextInt();
System.out.println("");
System.out.print("MATHS : " );
int math = sc.nextInt();
System.out.println("");
System.out.print("COMPUTER APPLICATIONS : ") ;
int comp = sc.nextInt();
System.out.println("");{
int sum = (phy+chem+math+comp);
double percentage = (sum
100)/400; //here I have taken the total marks 400[Which means each subject marks is out of 100]
System.out.println("YOUR PERCENTAGE : " + percentage);
}
}
}