Question

Program Specification: This project involves implementing a Java program that performs a calculation of payments associated with loans. The program shall allow a user to enter the following data: annual interest rate the loan (i.e. , number of years), and the loan amount. A GUI like the one below must be used. Loan Calculator Annual Interest Rate: Number of Years Loan Amount: Monthly Payment Total Payment Calculate When the user presses the calculate button, the monthly payment and total amount of payments shall be displayed. The formula for computing the monthly payment (P) is: i A where i - periodic interest rate, A amount of loan, n number of compounding periods (12). For example, if the annual interest rate is 5 percent, the term of the loan is 2 years, and th loan amount is $2,000, and interest is compounded monthly: ·05/12+ .00417 n = 2 * 12 = 24 P = S87.74 Total Payment : 24 * $87.74
0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* See the source code*/

import javax.swing.*;

import java.io.*;

import java.util.*;

import java.awt.event.*;

import java.awt.*;

class Solution extends JFrame

{

JLabel LblRate; //Label for Interest Rate

JLabel LblYear; //Label for Number of Year

JLabel LblAmount; //Label for Loan Amount

JLabel LblMPayment; //Label for Monthly payment

JLabel LblTPayment; //Label for Total Payment

JTextField TxtRate; //TextFiled for interst

JTextField TxtYear; //TextFiled for Years

JTextField TxtAmount; //TextFiled for Loan amount

JTextField TxtMPayment; //TextFiled for Monthly Payment

JTextField TxtTPayment; //Textfield for Total Payment

JButton BtnCalculate; //Button to calculate

Container c;

public Solution()

{

//Initialize all components

c=getContentPane();

c.setLayout(null);

int w=150,h=20,col=30,row=5;

BtnCalculate = new JButton("Calculate"); BtnCalculate.setBounds(col+180,row+110,w-30,h);

LblRate = new JLabel(); LblRate.setText("Annual Interest Rate:"); LblRate.setBounds(col,row,w,h);

LblYear = new JLabel(); LblYear.setText("Number of Years:"); LblYear.setBounds(col,row+20,w,h);

LblAmount = new JLabel(); LblAmount.setText("Loan Amount"); LblAmount.setBounds(col,row+40,w,h);

LblMPayment = new JLabel(); LblMPayment.setText("Monthly Payment:"); LblMPayment.setBounds(col,row+60,w,h);

LblTPayment = new JLabel(); LblTPayment.setText("Total Payment:"); LblTPayment.setBounds(col,row+80,w,h);

TxtRate = new JTextField(); TxtRate.setBounds(col+150,row,w,h);

TxtYear = new JTextField(); TxtYear.setBounds(col+150,row+20,w,h);

TxtAmount = new JTextField(); TxtAmount.setBounds(col+150,row+40,w,h);

TxtMPayment = new JTextField(); TxtMPayment.setEditable(false); TxtMPayment.setBounds(col+150,row+60,w,h);

TxtTPayment = new JTextField(); TxtTPayment.setEditable(false); TxtTPayment.setBounds(col+150,row+80,w,h);

//Add all components to layout

c.add(LblRate);

c.add(TxtRate);

c.add(LblYear);

c.add(TxtYear);

c.add(LblAmount);

c.add(TxtAmount);

c.add(LblMPayment);

c.add(TxtMPayment);

c.add(LblTPayment);

c.add(TxtTPayment);

c.add(BtnCalculate);

BtnCalculate.addActionListener(new BtnClick());

setSize(400,250);

setTitle("Tax Calculation");

setVisible(true);

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}

private class BtnClick implements ActionListener

{

//Set action on calculate button click

public void actionPerformed(ActionEvent ae)

{

//Get values & calculate based on given formula

float interest = Float.parseFloat(TxtRate.getText());

interest*=0.01;

interest/=12;

float years = Float.parseFloat(TxtYear.getText());

years*=12;

float amount = Float.parseFloat(TxtAmount.getText());

float monthlyPayment = (interest*amount)/(1-(float)Math.pow((1+interest),-years));

//Print the result

String formatedValue = String.format("%.2f", monthlyPayment);

TxtMPayment.setText(formatedValue);

formatedValue = String.format("%.2f", (years*monthlyPayment));

TxtTPayment.setText(formatedValue);

}

}

//Main method to run the application

public static void main(String arg[])

{

Solution obj = new Solution();

}

}

/* See the output*/

Add a comment
Know the answer?
Add Answer to:
Program Specification: This project involves implementing a Java program that performs a calculation of payments associated...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The program is in python :) Write a code program to calculate the mortgage payment. The...

    The program is in python :) Write a code program to calculate the mortgage payment. The equation for calculating the mortgage payment is: M = P (1+r)n (1+r)n-1 Where: M is your monthly payment P is your principal r is your monthly interest rate, calculated by dividing your annual interest rate by 12. n is your number of payments (the number of months you will be paying the loan) Example: You have a $100,000 mortgage loan with 6 percent annual...

  • MATLAB!!! CAN SOMEONE SOLVE THIS PROBLEM ON MATLAB?? THANK YOU PART B: HOUSING LOAN CALCULATOR In this part of the assignment, you are expected to develop a program that calculates housing loan pay-...

    MATLAB!!! CAN SOMEONE SOLVE THIS PROBLEM ON MATLAB?? THANK YOU PART B: HOUSING LOAN CALCULATOR In this part of the assignment, you are expected to develop a program that calculates housing loan pay- ments based on compound interest formulas The program should prompt a user to input the amount borrowed (principal), p, the number of monthly payments, n, and an annual interest rate in R percent. The program should convert the annual interest rate R into a monthly interest rate...

  • 19. Monthly Payments The monthly payment on a loan may be calculated by the following formula:...

    19. Monthly Payments The monthly payment on a loan may be calculated by the following formula: Rate (1Rate) ((1 Rate)N - 1) Payment - Rate is the monthly interest rate, which is the annual interest rate divided by 12" (12% annual interest would be 1 percent monthly interest.) N is the number of payments, and L is the amount of the loan. Write a program that asks for these values and displays a report similar to Loan Amount: Monthly Interest...

  • using Matlab program: Create a loan payment program that can be used for any loan amount...

    using Matlab program: Create a loan payment program that can be used for any loan amount such as a home or car loan. The program should ask the user for the input values below, compute the monthly payment, then compute the monthly balance. Display the balance in a table Month             Balance 1                      $ ##.## 2                      $ ##.## 3                      $ ##.##       . . . etc Use the formula PMT=P*(r(1+r)^n)/((1+r)^n-1) PMT = the monthly payment. P = the principal r = the interest rate per month, which...

  • My library>CptS 111 home> 2.9: zyLab PA #1: Student Loan R oks zyBooks cat @Help/FAQ θ...

    My library>CptS 111 home> 2.9: zyLab PA #1: Student Loan R oks zyBooks cat @Help/FAQ θ Mohammed Al Shukaili 2.9 zyLabPA#1:Student Loan RepaymentCalculator For this assignment you wil write a program to calculate the monthly payments required to pay back a student loan You vill need to prompt the user for the following values Annual interest rate (as a percentage) Number of years to repay loan . and display the output in a readable form. Output should include Amount of...

  • Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives...

    Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he or she is finished providing inputs. After the user presses the enter key, the program should print the sum of the numbers and their average. Q2. The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of...

  • c++ and please add tables and everything and make sure program is complete. Write a menu...

    c++ and please add tables and everything and make sure program is complete. Write a menu driven program, which would compute compound interest and a monthly payment for a loan. The user will be given a choice to display the info on the screen or to a filo Menu will be the following Enter (1) to calculate your loan monthly payment Enter (2) to calculate your loan monthly payment & write to a file Tips: Compound Interest Formula A =...

  • Write a python program for the below question? Car Loan If A dollars is borrowed at...

    Write a python program for the below question? Car Loan If A dollars is borrowed at r% interest compounded monthly to purchase a car with monthly payments for n years, then the monthly payment is given by the formula monthly payment = i / 1 - (1 + i)-12n . A where i = r/1200. Write a program that calculates the monthly payment after the user gives the amount of the loan, the interest rate, and the number of years.

  • You wish to buy a car for $12,000 at a 5% annual interest rate, compounded monthly....

    You wish to buy a car for $12,000 at a 5% annual interest rate, compounded monthly. The loan will be repaid in 5 years with monthly payments. What is your monthly payment (calculated with the equations on the next page)? Compare your answer to that obtained with the built in function, PMT. Be sure to label all cells appropriately. (There is no need to create a monthly payment table, simply use the equations on the next page.) Loans: where: and,...

  • Devise an app (use a GUI) to calculate and display loan repayments. The user will enter...

    Devise an app (use a GUI) to calculate and display loan repayments. The user will enter in a loan amount, term and interest rate. You calculate the periodic amount due and display it to the user. The formula you need is below. A=P{\frac {i(1+i)^{n}}{(1+i)^{n}-1}}={\frac {P\times i}{1-(1+i)^{{-n}}}}=P\left(i+{\frac {i}{(1+i)^{n}-1}}\right) where: A = periodic payment amount P = amount of principal i = periodic interest rate e.g. 7.5% per year / 12 months = 0.625% per period n = total number of payments...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT