Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class grade {
- static Scanner console=new Scanner(System.in);
- private static int counter;
- public static void main(String[]args){
- int[]items=new int[5];
- int choice;
- int g1,g2,g3,g4,ave;
- int grade=0;
- do{
- System.out.println("Menu");
- System.out.println("1.To compute your grade");
- System.out.println("2. Array");
- System.out.println("3.Exit");
- System.out.println("Enter number of your choice:");
- choice=console.nextInt();
- switch (choice)
- {
- case 1:
- System.out.println("Enter 4 of your grades");
- g1=console.nextInt();
- g2=console.nextInt();
- g3=console.nextInt();
- g4=console.nextInt();
- ave=((g1+g2+g3+g4)/4);
- if (ave>=75) {
- System.out.println("You passed!"+ave);
- }
- else {
- System.out.println("You failed!");
- }
- break;
- case 2:
- System.out.println("Enetr 5 integers:");
- for (int counter0; counter<5; counter ++)
- {
- items[counter]=console.nextInt();
- }
- break;
- case 3:
- System.out.println("Goodbye!");
- break;
- default:
- System.out.println("Invalid choice! Choose again.");
- }
- }
- while(choice!=3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment