Help! Stuck on that problem | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Help! Stuck on that problem

No zeroes from java not working import java.util.Scanner; import java.util.InputMismatchException; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); try { int num1 = scanner.nextInt(); int num2 = scanner.nextInt(); /* 1. Еrror: division by zero 2. Error: wrong value type */ //your code goes here if (num1 == 0) throw new ArithmeticExeption(); else {System.out.println(num1/num2);}} catch(ArithmeticExeption e1) {System.out.println("Error: division by zero");} catch(InputMismatchExeption e2) {System.out.println("Error: wrong value type");} } }

22nd Jan 2022, 12:55 PM
sebastien lalloz
sebastien lalloz - avatar
3 ответов
0
num2 has to be a not zero. Not num1, is fine if it is zero. edit : sebastien lalloz also you have spelling mistake in Exception, c missing in all..
22nd Jan 2022, 1:03 PM
Jayakrishna 🇮🇳
0
if(num2 ==0)
22nd Jan 2022, 7:47 PM
Adi Nath Bhawani
Adi Nath Bhawani - avatar
0
Thank you.
24th Jan 2022, 4:49 PM
sebastien lalloz
sebastien lalloz - avatar