Advertisement
Guest User

Menu Class

a guest
Apr 8th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.69 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Menu {
  5.  
  6.     public static void main(String[] args) {
  7.         boolean running = true;
  8.        
  9.         while(running)
  10.         {
  11.         menu();
  12.         running=again();
  13.         }
  14.     }
  15.    
  16.     public static void menu() {
  17.        
  18.         Scanner scanObj = new Scanner(System.in);
  19.         Operations opObj = new Operations();
  20.        
  21.         System.out.println("Which math tool would you like to use?");
  22.         System.out.println();
  23.         System.out.println("\t(1) Quadratic Formula");
  24.         System.out.println("\t(2) System of Two Linear Equations");
  25.         System.out.println("\t(3) Unavailable");
  26.         System.out.println("\t(4) Unavailable");
  27.         System.out.println();
  28.         System.out.print("Which one?:");
  29.        
  30.         int j = scanObj.nextInt();
  31.        
  32.         switch(j){
  33.         case 1: opObj.quadratic();
  34.                 break;
  35.         case 2: opObj.linear();
  36.                 break;
  37.         case 3: System.out.println("Not available yet. :("); //Idk what to do here.
  38.                 break;
  39.         case 4: System.out.println("Not available yet. :("); //Idk what to do.
  40.                 break;
  41.         default: System.out.println("You must input a number from 1 to 4!"); //If they give an invalid operation number.
  42.                 break;
  43.         }
  44.     }
  45.    
  46.     public static boolean again() {
  47.         Scanner scanObj = new Scanner(System.in);
  48.        
  49.         System.out.println("------------------------------------------------"); //Signify new section.
  50.         System.out.println("Would you like to do another? (1/0)");
  51.         System.out.println();
  52.         System.out.println("Yes(1) or No(0)?:");
  53.        
  54.         int j = scanObj.nextInt();
  55.        
  56.         System.out.println("------------------------------------------------"); //Signify new section.
  57.        
  58.         if(j==1)
  59.         return true;
  60.        
  61.         System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Signify program end.
  62.         return false;
  63.        
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement