100%(2)2 out of 2 people found this document helpful
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 lowIntRateDISPLAY "Enter the high interest rate:"Page 5of 43
Enter the highIntRateENDDO// Ended of checking the interestDISPLAY " Interest Rate " + " Monthly Payment " + " Total Payment "DOWHILE(lowIntRate<=highIntRate)RECEIVE Payment = calculateInt(loanAmount, years, lowIntRate)RECEIVE TotalPayment = (Payment * 12) * yearsDISPLAY lowIntRate, Payment, TotalPayment lowIntRate = lowIntRate + 0.2513)DISPLAY(“Do you want to continue? Y or N”)14)Enter the solution15)IF (solution==’Y’) Choice=TrueELSEChoice=FalseENDIFENDIFENDWHILE// Ended of the loop choice statementDISPLAY “You have ended the program”END// Ended of main16)Acceptation_input_ofInt()// Acceptation of input is integer for functionWHILEDO(NOT IntInput)Display “Please enter the numbers:” Receive IntInputENDDORETURN IntInputEND// Ended of function checking the integer17)Acceptation_input_ofDouble()// Acceptation of input is double for functionWHILEDO(NOT DoubleInput)Display “Please enter the numbers:” Receive DoubleInputENDDORETURN DoubleInputEND// Ended of function checking the double18)calculateInt (loanAmount, years, interestRate)RECEIVE monthlyRate = interestRate / 1200RECEIVE monthPayment = (loanAmount * monthlyRate) / (1 - (1 / (Math.pow(1 + monthlyRate, years * 12))))RETURN monthPaymentENDPage 6of 43
Flow chart diagram of the program:Page 7of 43
Page 8of 43
Page 9of 43
By accepting of check the program, which had been done. The program is unable toaccept 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 objectstatic Scanner reading = new Scanner(System.in);public static void main(String[] args) { double loanAmount;int years;Page 10of 43
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 paymentwhile(choice) {// Enter the loan amountSystem.out.print("Enter the loan amount:");loanAmount = ofDouble();// To check whether the input is equal to and less than zerowhile (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:");