the high interest rate DISPLAY Error message low interest rate is more than the

The high interest rate display error message low

This preview shows page 5 - 12 out of 43 pages.

// the high interest rate DISPLAY "Error message, low interest rate is more than the high interest rate" DISPLAY "Enter the low interest rate:" Enter the lowIntRate DISPLAY "Enter the high interest rate:" Page 5 of 43
Image of page 5
Enter the highIntRate ENDDO // Ended of checking the interest DISPLAY " Interest Rate " + " Monthly Payment " + " Total Payment " DOWHILE(lowIntRate<=highIntRate) RECEIVE Payment = calculateInt(loanAmount, years, lowIntRate) RECEIVE TotalPayment = (Payment * 12) * years DISPLAY lowIntRate, Payment, TotalPayment lowIntRate = lowIntRate + 0.25 13) DISPLAY(“Do you want to continue? Y or N”) 14) Enter the solution 15) IF (solution==’Y’) Choice=True ELSE Choice=False ENDIF ENDIF ENDWHILE // Ended of the loop choice statement DISPLAY “You have ended the program” END // Ended of main 16) Acceptation_input_ofInt() // Acceptation of input is integer for function WHILEDO(NOT IntInput) Display “Please enter the numbers:” Receive IntInput ENDDO RETURN IntInput END // Ended of function checking the integer 17) Acceptation_input_ofDouble() // Acceptation of input is double for function WHILEDO(NOT DoubleInput) Display “Please enter the numbers:” Receive DoubleInput ENDDO RETURN DoubleInput END // Ended of function checking the double 18) calculateInt (loanAmount, years, interestRate) RECEIVE monthlyRate = interestRate / 1200 RECEIVE monthPayment = (loanAmount * monthlyRate) / (1 - (1 / (Math.pow(1 + monthlyRate, years * 12)))) RETURN monthPayment END Page 6 of 43
Image of page 6
Flow chart diagram of the program: Page 7 of 43
Image of page 7
Page 8 of 43
Image of page 8
Page 9 of 43
Image of page 9
By accepting of check the program, which had been done. The program is unable to accept the input for zero and keep repeating until the user to enter the correct input. 7) Source program listings: package loanpayment; import java.util.Scanner; public class LoanPayment { // The program will let the user to enter loan amount and calculate the // monthly and total payment of each interest rate // To create a Scanner which has static object static Scanner reading = new Scanner(System.in); public static void main(String[] args) { double loanAmount; int years; Page 10 of 43
Image of page 10
double lowIntRate; double highIntRate; char solution; boolean choice = true; StudentID(); // Loan amount, loan period and annual interest rate is not an negative number and // display a table form of the monthly paymentand the total payment while(choice) { // Enter the loan amount System.out.print("Enter the loan amount:"); loanAmount = ofDouble(); // To check whether the input is equal to and less than zero while (loanAmount <= 0) { System.out.println("The loan amount is equal to and less than Zero, Please re-type it again"); System.out.print("Enter the loan amount:");
Image of page 11
Image of page 12

You've reached the end of your free preview.

Want to read all 43 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture