Error creating a calculator with java | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Error creating a calculator with java

I wrote a code to make a java calculator I run it but the SoloLearn playground donā€™t allow me to take in my user input I tried this on another app compiler and it works fine what do I do The code link https://code.sololearn.com/cP9BMOUL5lNu/?ref=app

12th Jul 2021, 4:37 PM
Abdul Yusuf
Abdul Yusuf - avatar
9 Respostas
+ 3
System.out.printf("product of both numbers is: %d", product);
12th Jul 2021, 5:27 PM
Ciro Pellegrino
Ciro Pellegrino - avatar
+ 2
Insert your code in your question
12th Jul 2021, 4:43 PM
Jawahirullah
Jawahirullah - avatar
+ 2
alternatively cast ti float or double System.out.printf("product of both numbers is: %f", (double)product);
12th Jul 2021, 5:07 PM
Ciro Pellegrino
Ciro Pellegrino - avatar
+ 1
Please comment answers to help
12th Jul 2021, 4:38 PM
Abdul Yusuf
Abdul Yusuf - avatar
0
comment what? what is the source? what is the input sequence you are trying? the fried air cannot be commented on Use the other app as it works
12th Jul 2021, 4:47 PM
Ciro Pellegrino
Ciro Pellegrino - avatar
0
I just added the code
12th Jul 2021, 4:59 PM
Abdul Yusuf
Abdul Yusuf - avatar
0
because you read two integers, you store the product in an integer and then try to display a float. Use %d not %f in the input box test 5 6 and submit. unfortunately the rendering in the playground is not that of the execution on the pc but It works
12th Jul 2021, 5:02 PM
Ciro Pellegrino
Ciro Pellegrino - avatar
0
Ciro pellegrino thanks it worked but the outputs are in decimals e.g 4.0000 How do i make the output be in integer or whole numbers
12th Jul 2021, 5:22 PM
Abdul Yusuf
Abdul Yusuf - avatar
0
System.out.printf("product of both numbers is: %d", product);
12th Jul 2021, 5:34 PM
Solo
Solo - avatar