Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Menu {
- public static void main(String[] args) {
- boolean running = true;
- while(running)
- {
- menu();
- running=again();
- }
- }
- public static void menu() {
- Scanner scanObj = new Scanner(System.in);
- Operations opObj = new Operations();
- System.out.println("Which math tool would you like to use?");
- System.out.println();
- System.out.println("\t(1) Quadratic Formula");
- System.out.println("\t(2) System of Two Linear Equations");
- System.out.println("\t(3) Unavailable");
- System.out.println("\t(4) Unavailable");
- System.out.println();
- System.out.print("Which one?:");
- int j = scanObj.nextInt();
- switch(j){
- case 1: opObj.quadratic();
- break;
- case 2: opObj.linear();
- break;
- case 3: System.out.println("Not available yet. :("); //Idk what to do here.
- break;
- case 4: System.out.println("Not available yet. :("); //Idk what to do.
- break;
- default: System.out.println("You must input a number from 1 to 4!"); //If they give an invalid operation number.
- break;
- }
- }
- public static boolean again() {
- Scanner scanObj = new Scanner(System.in);
- System.out.println("------------------------------------------------"); //Signify new section.
- System.out.println("Would you like to do another? (1/0)");
- System.out.println();
- System.out.println("Yes(1) or No(0)?:");
- int j = scanObj.nextInt();
- System.out.println("------------------------------------------------"); //Signify new section.
- if(j==1)
- return true;
- System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Signify program end.
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement