Which is output when inputVal is -5?
try { inputVal = scnr.nextInt(); if (inputVal < 0) { throw new Exception("Input should bepositive"); } System.out.print("Input squared: " + inputVal *inputVal);}catch (Exception e) { System.out.print(e.getMessage());}
Input squared: 25
Exception
Input should be positive
Input squared: 25Input should be positive
Which is output when inputVal is -5? try { inputVal = scnr.nextInt(); if (inputVal < 0) { throw new Except
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am