janicegutierrez86

java with operation and array

Oct 5th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.69 KB | None | 0 0
  1.  
  2. import java.util.*;
  3. public class grade {
  4.     static Scanner console=new Scanner(System.in);
  5.     private static int counter;
  6.     public static void main(String[]args){
  7.  
  8.         int[]items=new int[5];
  9.         int choice;
  10.         int g1,g2,g3,g4,ave;
  11.         int grade=0;
  12.                
  13.                 do{
  14.                     System.out.println("Menu");
  15.                     System.out.println("1.To compute your grade");
  16.                     System.out.println("2. Array");
  17.                     System.out.println("3.Exit");
  18.                             System.out.println("Enter number of your choice:");
  19.                             choice=console.nextInt();
  20.                            
  21.                             switch (choice)
  22.                                 {
  23.                                 case 1:
  24.                                     System.out.println("Enter 4 of your grades");
  25.                                     g1=console.nextInt();
  26.                                     g2=console.nextInt();
  27.                                     g3=console.nextInt();
  28.                                     g4=console.nextInt();
  29.                                     ave=((g1+g2+g3+g4)/4);
  30.                                    
  31.                                     if (ave>=75) {
  32.                         System.out.println("You passed!"+ave);
  33.                     }
  34.                                     else {
  35.                         System.out.println("You failed!");
  36.                     }
  37.                                    break;
  38.                                    
  39.                                 case 2:
  40.                                     System.out.println("Enetr 5 integers:");
  41.                                             for (int counter0; counter<5; counter ++)
  42.                                    {
  43.                                        items[counter]=console.nextInt();
  44.                                        
  45.                                    }
  46.                                     break;
  47.                                    
  48.                                 case 3:
  49.                                     System.out.println("Goodbye!");
  50.                                    
  51.                                    break;
  52.                                    
  53.                                 default:
  54.                                     System.out.println("Invalid choice! Choose again.");
  55.                                    
  56.                                    
  57.                                    
  58.                                    
  59.                                    
  60.                             }
  61.    
  62.                  
  63.                 }
  64.                 while(choice!=3);
  65.            
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment