From a23793f5e1f402545c5e02417c1909fbf69d32b1 Mon Sep 17 00:00:00 2001 From: school Date: Tue, 4 Dec 2018 21:57:59 -0600 Subject: [PATCH] MathFuntion was the name of the class --- files/MathProblems.java | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) 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(); - } - - - - }