Object-Oriented Programming Loan Calculator Assignment
VerifiedAdded on 2025/05/04
|5
|396
|360
AI Summary
Desklib provides solved assignments and past papers for students.

MITS4002
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity07
Student ID:
Student full name:
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity07
Student ID:
Student full name:
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

A program that lets the user enter the loan amount and loan period in a number of
years and displays the monthly and total payments for each interest rate starting
from 5% to 8%, with an increment of 1/8.
Analysis
It is required to develop a program that could allow a user to calculate loan by entering loan
tenure and loan amount including number. This program provides a visual display for monthly
payment including the interest rate.
So the program will take a number as an input from the user and guide the user to enter a key.
The system only accepts a numerical number from 0 to 9. It then asks for another input for loan
tenure which is also a number from 0 to 9. The system asks the user to enter a letter and check
loan tenure and monthly payment including interest.
Design
The major step that is required to solve the current problem is as follows:
Step1: Assign letters to the associated number i.e. 0 to 9.
Step2: Take input from users:
If a user select and enter key, the program would display the assigned letter
If a user selects and click on any symbol then an error message would be generated,
display to the user.
Coding
Import java.util.Scanner;
Public class ComparingLoans {
double InterestRate;
double Increment = 0.125;
double MonthlyPayment;
double TotalPayment;
int LoanAmount;
int NoOfYears;
public void userInput(){
Scanner sc = new Scanner(System.in);
System.out.print("Loan Amount ");
LoanAmount = sc.nextInt();
if(LoanAmount<= 0){
System.out.println("Wrong Input!! Loan Amount can not be 0
or negative");
System.exit(0);
}
years and displays the monthly and total payments for each interest rate starting
from 5% to 8%, with an increment of 1/8.
Analysis
It is required to develop a program that could allow a user to calculate loan by entering loan
tenure and loan amount including number. This program provides a visual display for monthly
payment including the interest rate.
So the program will take a number as an input from the user and guide the user to enter a key.
The system only accepts a numerical number from 0 to 9. It then asks for another input for loan
tenure which is also a number from 0 to 9. The system asks the user to enter a letter and check
loan tenure and monthly payment including interest.
Design
The major step that is required to solve the current problem is as follows:
Step1: Assign letters to the associated number i.e. 0 to 9.
Step2: Take input from users:
If a user select and enter key, the program would display the assigned letter
If a user selects and click on any symbol then an error message would be generated,
display to the user.
Coding
Import java.util.Scanner;
Public class ComparingLoans {
double InterestRate;
double Increment = 0.125;
double MonthlyPayment;
double TotalPayment;
int LoanAmount;
int NoOfYears;
public void userInput(){
Scanner sc = new Scanner(System.in);
System.out.print("Loan Amount ");
LoanAmount = sc.nextInt();
if(LoanAmount<= 0){
System.out.println("Wrong Input!! Loan Amount can not be 0
or negative");
System.exit(0);
}

System.out.print("Number of Years ");
NoOfYears = sc.nextInt();
if(NoOfYears<= 0){
System.out.println("Wrong Input!! Years can not be 0 or
negative");
System.exit(0);
}
}
public void payment()
{
InterestRate= 5.000;
System.out.println("Interest Rate \t\t Monthly Payment \t\t Total
Payment");
while(InterestRate<= 8.000)
{
double MonthlyInterestRate = (InterestRate/100) / 12;
MonthlyPayment = (LoanAmount *
MonthlyInterestRate)/(1-(1/(Math.pow((1 + MonthlyInterestRate), (12 *
NoOfYears)))));
TotalPayment = MonthlyPayment * 12 * NoOfYears;
System.out.printf("%.3f", InterestRate);
System.out.print(" \t \t \t ");
System.out.printf("%.2f", MonthlyPayment);
System.out.print(" \t \t \t ");
System.out.printf("%.2f", TotalPayment);
System.out.println();
InterestRate += Increment;
}
}
public static void main(String[] args) {
ComparingLoans cl = new ComparingLoans();
cl.userInput();
cl.payment();
}
}
NoOfYears = sc.nextInt();
if(NoOfYears<= 0){
System.out.println("Wrong Input!! Years can not be 0 or
negative");
System.exit(0);
}
}
public void payment()
{
InterestRate= 5.000;
System.out.println("Interest Rate \t\t Monthly Payment \t\t Total
Payment");
while(InterestRate<= 8.000)
{
double MonthlyInterestRate = (InterestRate/100) / 12;
MonthlyPayment = (LoanAmount *
MonthlyInterestRate)/(1-(1/(Math.pow((1 + MonthlyInterestRate), (12 *
NoOfYears)))));
TotalPayment = MonthlyPayment * 12 * NoOfYears;
System.out.printf("%.3f", InterestRate);
System.out.print(" \t \t \t ");
System.out.printf("%.2f", MonthlyPayment);
System.out.print(" \t \t \t ");
System.out.printf("%.2f", TotalPayment);
System.out.println();
InterestRate += Increment;
}
}
public static void main(String[] args) {
ComparingLoans cl = new ComparingLoans();
cl.userInput();
cl.payment();
}
}
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

Output screenshot
Testing
Enter a number to show year could not be 0 or negative.
The Loan amount cannot be entered 0 or negative.
Testing
Enter a number to show year could not be 0 or negative.
The Loan amount cannot be entered 0 or negative.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

1 out of 5
Related Documents

Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.