Java School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Mortgage Payment Calculator Create a java program that will display the value of three mortgage pa Rate Topic: -----

#1 tommyb09  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-December 08


Dream Kudos: 0

Share |

Mortgage Payment Calculator

Post icon  Posted 08 December 2008 - 01:51 PM

Hello,

If anyone can give me some help of where I am going wrong with creating a java program that will display the mortgage payments of three mortgage loans using a GUI I will be most thankful to you. When I am trying to compile my file, I am receiving 1 error for int b; a; //Counted Loop as well as Exception in thread "main" java.lang.ClassFormatError when I try and run the file. Here is what I have so far.

/*
PRG421: McBride Financial Services SR-mf-003 (Week 3)
Programmer: Thomas Bowden, Jr.
Date: December 8, 2008
Filename: MortgageCalculator2.java
Purpose: Create a Java program that will display mortgage payments
for 3 mortgage loans using a GUI.
- 7 year at 5.35%
- 15 year at 5.5%
- 30 year at 5.75%
//Use an array for different loans.
//Display the mortgage payments for each loan.

*/

import java.lang.Math.*;
import java.text.*;
import java.io.*;

public class MortgageCalculator2
{
	public static void main(String[] arg)
	{
		double pLoan = 200000; //total loan amount
		double pTerm[] = {7, 15, 30}; //payment term
		double pAPR[] = {0.0535, 0.055, 0.0575}; //interest rate
		double pMortgage[] = {0, 0, 0};
		double pBalance[] = {0, 0, 0};
		int b; a; //Counted Loop

		for (b = 0; b < 3; b++)
		{
			//lets calculate mortgage monthly payments
			pMortgage[b] = pLoan * dAPR[b] / (1- Math.pow((1 + pAPR[b]), -pTerm[b]))
			/12;
			pBalance[b] = pLoan;
		}
		System.out.println("Three Monthly Loan Computations");
		//display initial footer
		System.out.println("===============================");
		footer(b, dMortgage[0], dMortgage[1], dMortgage[2]);

		for (b = 1; b <= (dLoan[2] * 12); b++)
		//Looping payments post-incremented by 1
		{
			for (a=0; a<3; a++)
			{
				if (pBalance[a] > 0.01) //verifies balance
				{
					System.out.format(" %-8.2f%a", a, pBalance[a] * (pTerm[a] / 12));
					//justifies interest paid
					pBalance[a] -= pMortgage[a] - pBalance[a] * (pAPR[a] / 12);
					//modifying balance
				}
				else
				{
					System.out.format(",");
				}
			}
			System.out.println();

			if(b % 12 == 0 && b < dTerm[2] * 12) //reiterates footer after every fiscal year
			{
				footer(b, pMortgage[0], pMortgage[1], pMortgage[2]);
			}
		}
	}
	private static void footer(int b, double pMortgage0, double pMortgage1, double pMortgage2) throws IOException
	//footer methodology
	{
		if ((b/12+1) % 2 != 0 && b>12) //Displays payment bi-yearly
		{
			System.out.println("Press Enter to perform the next 2 fiscal years");
		}

		if (b>12)
		{
			System.in.read();
		}
		System.out.println();
		System.out.format("Term payments on $200,000 Loan #%d", a/12+1);
		System.out.format("5.35%% @ 7yrs $%.2f/mo   5.50%% @ 15yrs $%.2f/mo   5.75%% @ 30yrs $%.2f/mo", pMortgage0, pMortgage1, pMortgage2);
		System.out.println("Interest Paid Balance   Interest Paid Balance   Interest Paid Balance");
		System.out.println("------- -------------   ------- -------------   ------- -------------   -------- ------------- -----------");
	}
}



*Edited to add the [ code] tags. Please :code:

This post has been edited by pbl: 08 December 2008 - 07:02 PM

Was This Post Helpful? 0
  • +
  • -


#2 mostyfriedman  Icon User is online

  • The Algorithmi
  • Icon

Reputation: 455
  • Posts: 3,761
  • Joined: 24-October 08


Dream Kudos: 600

Expert In: Learning

Re: Mortgage Payment Calculator

Posted 08 December 2008 - 01:56 PM

first correction,
int a, b;

could you please place your code between[ code ] [ /code ] and also ident your braces etc....it would be much easier to read

This post has been edited by mostyfriedman: 08 December 2008 - 01:57 PM

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users