Browse Source

MathFuntion was the name of the class

master
school 7 years ago
parent
commit
a23793f5e1
  1. 22
      files/MathProblems.java

22
files/MathProblems.java

@ -8,34 +8,30 @@ public class MathProblems
public void divide() public void divide()
{ {
Scanner input = new Scanner(System.in); Scanner input = new Scanner(System.in);
int a=1;
int b=1;
try try
{ {
System.out.print("Enter a: "); System.out.print("Enter a: ");
int a = input.nextInt();
a = input.nextInt();
System.out.print("Enter b: "); System.out.print("Enter b: ");
int b = input.nextInt();
b = input.nextInt();
} }
catch(InputMismatchException ime) 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 ) public static void main( String[] args )
{ {
// Test it here in main, when ready // Test it here in main, when ready
MathFunctions functions = new MathFunctions();
MathProblems functions = new MathProblems();
functions.divide(); functions.divide();
} }
} }
Loading…
Cancel
Save