JAVA Simple Calculator remove decimal places | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

JAVA Simple Calculator remove decimal places

Can anyone teach me how to remove decimal places if the answer is a whole number?

28th Sep 2019, 1:01 PM
Joseph Brendon Jon I. Loremia
Joseph Brendon Jon I. Loremia - avatar
3 Respostas
+ 1
FOLLOW ME You can convert theĀ doubleĀ value into aĀ intvalue.Ā int x = (int) yĀ where y is your double variable. Then, printingĀ xĀ does not give decimal places (15000Ā instead ofĀ 15000.0).
28th Sep 2019, 1:10 PM
KfirWe
KfirWe - avatar
+ 1
ill try . thanks for your help ā¤ļø
28th Sep 2019, 1:11 PM
Joseph Brendon Jon I. Loremia
Joseph Brendon Jon I. Loremia - avatar
0
great . thanks for your help
28th Sep 2019, 2:35 PM
Joseph Brendon Jon I. Loremia
Joseph Brendon Jon I. Loremia - avatar