¿ Cual es el error ? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

¿ Cual es el error ?

Estoy intentando completar un ejercicio java. Pero en la formula me encuentro un error. Que no se como resolver. El ejercicio es sacar el total de 6 meses restando el 10℅ de cada mes con la cantidad total: ejemplo: entrada:int a= 5; mes 1: 10℅ a=0.5; a=a-0.5;......mes 6; aqui esta mi codigo: https://code.sololearn.com/c4lBatPGaul7/?ref=app Y la pregunta es: https://www.sololearn.com/coach/949?ref=app

13th Jan 2021, 2:13 AM
Daniel Briceño
Daniel Briceño - avatar
3 Antworten
+ 6
Decimals will be lost if we use int instead of double https://code.sololearn.com/cvO64pGOwZ4y/?ref=app
13th Jan 2021, 4:08 AM
Simba
Simba - avatar
+ 1
Please try to give a simple but detailed explanation of what you did. But thank you very much. : )
13th Jan 2021, 4:27 AM
Daniel Briceño
Daniel Briceño - avatar
+ 1
...... Convert from 1000 to 100 multiplied by 0.1. And since it is an integer, the decimal is lost. So you could get 10℅. For example: 10℅ 105==10.5;(int)10.5==10; 105*0.1==10.5;(int)10.5==10;
13th Jan 2021, 4:36 AM
Daniel Briceño
Daniel Briceño - avatar