import java.util.Scanner;
public class LoanProgram2{
public static void main (String [] args){
Scanner input= new Scanner(System.in);
System.out.println("Enter the loan amount: ");
double InitialAmountLoan = input.nextDouble();
System.out.println("Enter interest rate: ");
double AnnualInterestRate = input.nextDouble();
System.out.println("Please enter the monthly repayment amount> ");
double MonthlyRepayment = input.nextDouble();
double InitialBalance = +InitialAmountLoan;
System.out.println("Original loan Amount = " +InitialBalance );
System.out.println();
double InitialInterestRate = +AnnualInterestRate;
System.out.println("Interest rate is = " +InitialInterestRate );
System.out.println();
double InitialMonthlyPayment = +MonthlyRepayment;
System.out.println("Monthly Payment is = " +InitialMonthlyPayment);
System.out.println();
double AmountOfInterest =0;
double MonthlyRate = (+AnnualInterestRate/100) /12;
double Balance =InitialAmountLoan + (+InitialAmountLoan * +MonthlyRate) - +MonthlyRepayment;
int count = 1;
System.out.println("Balance at Month " +count+ " is " +Balance+ " after making a payment of " +MonthlyRepayment );
System.out.println();
while (Balance > 0){
if (Balance > 100)
Balance = Balance + (+Balance * +MonthlyRate) - +MonthlyRepayment;
else if (Balance <9)
break;
count = count +1;
System.out.println("Balance at Month " +count+ " is " +Balance+ " after making a payment of " +MonthlyRepayment );
System.out.println();
}
System.out.println("Loan will take " +count+ " months to pay off a lone of " +InitialAmountLoan);
}
}
THIS ARE THE VALUES I USED TO TEST THE PROGRAM
100000, 6.5 AND 1500 FOR THIS RUN FINE
BUT FOR THIS "100000, 6.5 AND 200"I WANT IT TO STOP AND PRINT "IT IS TO LOW"
PLEASE, HELP ME FIND SOLUTION TO THIS. THANKS