hey guys, i have to do this program and i'm having trouble with this certain part:

Write a program that lets the user enter the loan amount and loan period in 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.


Example: If you enter the loan amount 10,000 for 5 years; display a table as follows:


Loan Amount: 10000
Number of Years: 5


Interest Rate Monthly Payment Total Payment
5% 188.71 11322.74
5.125% 189.28 11357.13
5.25% 189.85 11391.59
...

7.85% 202.16 12129.97
8.0% 202.76 12165.83


This is what I have so far

import javax.swing.JOptionPane;
public class Loans
{
public static void main(String[] args);
{
double rate;
double monthlyPayment;
double loanAmount;
double total;
int numberOfYears;

//rate
// Need to prompt for the loan amount, outside the loop
// Need to prompt for the number of years outside the loop

for(rate = 5.0; rate <=8.0; rate=rate + 0.125)
{

// Enter Loan Amount
String loanAmountString = JOptionPane.showInputDialog("Enter loan amount:");

// convert rate to monthlyrate
// monthlyrate = rate / 1200; // 12 for the number of months and 100 to make a percentage
// calculate monthly payment
// monthlypayment = loanAmount * monthlyrate / ( 1 - 1 (Math.pow(1 + monthlyrate, numberOfYears * 12));
// display monthly payment

// calculate yearly payment
// yearly = monthlypayment * 12;


**** so im having trouble with some of the calculations and stuff. can someone please help me. i think i have most of the stuff already.

Code tags. Use them. . and I don't see where your error is. Be more specific. And also, most if not all of the posters here have no idea mathematically speaking what calculations you need to be using. If you tell us what the calculations are, in math speak or in plain English, we can help you figure out the code though.

normally such assignments provide a formula to work it out?

P = (Pv*R) / [1 - (1 + R)^(-n)]

that formula will work out the monthly payments ...

where
Pv = amount of loan
APR = Annual Percentage Rate (one year time period)
R = Periodic Interest Rate = APR/ # of interest periods per year
P = Monthly Payment
n = # of interest periods for overall time period (i.e., interest
periods per year * number of years)


source : http://mathforum.org/library/drmath/view/67057.html

Edited 6 Years Ago by phoenix911: n/a

This article has been dead for over six months. Start a new discussion instead.