0
Loan Calculator quiz am i missing something
The loan calculator quiz asks for an output of total amount left to pay after paying 10% back once a month for 6 months. int amount = scanner.nextInt(); int payment=0; int months=0; while(months <6) { payment = amount/10; amount = amount -payment; months++; } This was my answer and it said i was one dollar off. How do i correct the rounding?
1 Answer
+ 2
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double amount = scanner.nextInt();
//your code goes here
int i=0;
do{
amount=amount-(Math.ceil(amount/10));
i++;
}
while(i<6);
System.out.println((int)amount);
}
}
You need to use math.ceil method also use do while loop.