Created
September 10, 2012 20:09
-
-
Save anonymous/3693501 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package menucalc; | |
import java.util.*; | |
/** | |
* | |
* @author Josh | |
*/ | |
public class Input { | |
public int menuChoice; | |
public int choice1; | |
public int choice2; | |
public int choices[] = {0, 0}; | |
Scanner input = new Scanner(System.in); | |
public int menuInput() throws InputMismatchException { | |
System.out.println("Which operation would you like to do?"); | |
menuChoice = input.nextInt(); | |
return menuChoice; | |
} | |
public int[] chooseNumbers() throws InputMismatchException { | |
System.out.print("What is your first number? "); | |
choice1 = input.nextInt(); | |
System.out.print("What is your second number? "); | |
choice2 = input.nextInt(); | |
choices[0] = choice1; | |
choices[1] = choice2; | |
return choices; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package menucalc; | |
/** | |
* | |
* @author Josh | |
*/ | |
public class Math { | |
static int answer; | |
static Input Input = new Input(); | |
public static int doAddition(int a, int b) { | |
return (a + b); | |
} | |
public static int doSubtraction(int a, int b) { | |
if (a > b) { | |
answer = a - b; | |
} else if (a < b) { | |
answer = b - a; | |
} | |
return answer; | |
} | |
public static int doMultiplication(int a, int b) { | |
return (a * b); | |
} | |
public static int doDivision(int a, int b) { | |
return (a / b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment