Tuesday, July 22, 2014

Asking User to Input Grades then Show the Result in Java

import java.util.Scanner;
public class abejeroact6 {
public static void main (String[] arg) {
Scanner abejeroact6 = new Scanner(System.in);
int grade1;
int grade2;
int grade3;
int grade4;
int grade5;
int sum;
int ave;
System.out.println("Enter the value for Grade1");
grade1 = abejeroact6.nextInt();
System.out.println("Enter the value for Grade2");
grade2 = abejeroact6.nextInt();
System.out.println("Enter the value for Grade3");
grade3 = abejeroact6.nextInt();
System.out.println("Enter the value for Grade4");
grade4 = abejeroact6.nextInt();
System.out.println("Enter the value for Grade5");
grade5 = abejeroact6.nextInt();
sum = grade1+grade2+grade3+grade4+grade5;
ave = sum/5;
System.out.println("Average of the Student\t" +(ave));
}
}

No comments:

Post a Comment