0
My Java code is not giving exact output. (module project given by solo lesson 10), what is correct code please
Problem with decimals it is taking 111.1 as 112 but output is showing 111 https://code.sololearn.com/cWzSlYU3wGi7/?ref=app
2 Answers
+ 2
for(int x = 0; x < 6; x++){
amount -= (amount * 0.10);
}
+ 1
Dhanya Raj Ravi
Do like this
double amount = scanner.nextDouble();
for (int x=1; x<=6; ++x) {
amount -= Math.ceil(amount / 10);
}
System.out.println((int) amount);