Loan Calculator- When I execute the code, it passess the first two tests only. What am I missing here?
I know you can solve this in many ways and maybe in more efficient ways, but this is the first way I think of. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //your code goes here int firstmonth=0; int secondmonth=0; int thirdmonth=0; int remainingTotal=0; for(int months=1; months<=3; months++) { if(months==1) { int paymentOne = amount/100 *10; int remainingAmount = amount - paymentOne; firstmonth = remainingAmount; } if(months==2) { int paymenTwo=firstmonth/100 *10; secondmonth = firstmonth-paymenTwo; } if(months==3){ int paymenThree = secondmonth/100 *10; thirdmonth = secondmonth-paymenThree; } } remainingTotal = thirdmonth; System.out.println(remainingTotal); } }