20th Jul 2017, 6:42 AM
esraa ragab
5 Respostas
+ 2
Your Calculator.add() method takes 2 doubles as parameters and returns a double. An int can be passed into a method that takes a double just fine as it is implicitly converted. The problem however, is that you are using nextInt() to receive the input from the user. If the user inputs a floating point type you'll get an InputMismatchException as a double is not an int. double res =Calculator.add(sc.nextInt(),sc.nextInt()); change this line to: double res =Calculator.add(sc.nextDouble(),sc.nextDouble());
20th Jul 2017, 7:45 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Remember, Sololearn runs on a virtual machine on a server, thus you'll need the enter all the values in one input. You split multiple inputs by pressing {ENTER} ex: Input: 6 7 Output: 11.00
20th Jul 2017, 7:12 AM
Limitless
Limitless - avatar
+ 1
oh! lfound it l entered the val as6.0 8.0 so give me error
20th Jul 2017, 7:34 AM
esraa ragab
0
its adding the numbers bro
20th Jul 2017, 7:10 AM
Nirmal Kumar Bhakat
Nirmal Kumar Bhakat - avatar
0
but not work with me only throw exception lam enter 8 9 but only throw exception
20th Jul 2017, 7:32 AM
esraa ragab