Using User defined Input create a java code of this output.
Output:
Enter your name: Kevin Alonzo
Enter grade in Math: 90
Enter grade in English: 88
Enter grade in Filipino: 98
Enter grade in Science: 87
Enter grade in: P.E: 98
Kevin Alonzo This is your GPA.
This is your GPA 92.2
import java.util.*;
class App {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = keyboard.nextLine();
System.out.print("Enter grade in Math: ");
int Math = keyboard.nextInt();
System.out.print("Enter grade in English: ");
int English = keyboard.nextInt();
System.out.print("Enter grade in Filipino: ");
int Filipino = keyboard.nextInt();
System.out.print("Enter grade in Science: ");
int Science = keyboard.nextInt();
System.out.print("Enter grade in: P.E: ");
int PE = keyboard.nextInt();
System.out.print("Kevin Alonzo This is your GPA.\n");
double GPA = (Math + English + Filipino + Science + PE) / 5.0;
System.out.printf("This is your GPA %.1f\n", GPA);
keyboard.close();
}
}
Comments
Leave a comment