From 4f45151d9e2f140811b06f5abdfce76cb2375e9a Mon Sep 17 00:00:00 2001 From: school Date: Tue, 4 Dec 2018 12:56:13 -0600 Subject: [PATCH] started on mathproblems --- files/MathProblems.java | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/files/MathProblems.java b/files/MathProblems.java index 6972d4c..9088149 100644 --- a/files/MathProblems.java +++ b/files/MathProblems.java @@ -3,16 +3,19 @@ public class MathProblems { // Implement this method, which prompts the user for a and b, then divides a by b - // and then calculates a % b. If the user enters an invalid type of input, or a + // and then calculates a % b. If the user enters an invalid type of input, or a // zero for the divisor, an Exception will be thrown, both of which need to be caught public void divide() { - + Scanner input = new Scanner(System.in); try { - + System.out.print("Enter a: "); + int a = input.nextInt(); + System.out.print("Enter b: "); + int b = input.nextInt(); } - catch( ) + catch(InputMismatchException ime) { } @@ -20,18 +23,18 @@ public class MathProblems { } - + } - + public static void main( String[] args ) { // Test it here in main, when ready MathFunctions functions = new MathFunctions(); - + functions.divide(); - + } - +