diff --git a/files/MathProblems.java b/files/MathProblems.java index 9088149..c2c71da 100644 --- a/files/MathProblems.java +++ b/files/MathProblems.java @@ -8,34 +8,30 @@ public class MathProblems public void divide() { Scanner input = new Scanner(System.in); + int a=1; + int b=1; try { System.out.print("Enter a: "); - int a = input.nextInt(); + a = input.nextInt(); System.out.print("Enter b: "); - int b = input.nextInt(); + b = input.nextInt(); } catch(InputMismatchException ime) { - + System.out.println("Invalid input type"); } - catch( ) + catch(ArithmeticException ae) { - + System.out.println("You can't divide "+a+" by "+b); } - + } public static void main( String[] args ) { // Test it here in main, when ready - MathFunctions functions = new MathFunctions(); - + MathProblems functions = new MathProblems(); functions.divide(); - } - - - - }