Decimal places

My mortgage payment shows 13 decimal places

Page 1 of 1

1 Replies - 1445 Views - Last Post: 12 June 2007 - 09:18 PM Rate Topic: -----

#1 PonyDriver  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 27-April 07

Decimal places

Post icon  Posted 12 June 2007 - 07:58 PM

Hi,

I was hoping someone could point me in the direction of two decimal places. Thank you in advance.

/*
	Week 2:			Mortgage Calculator
	Programmer:		Tim Shannon
	Date:			June 11, 2007
	Filename:		MtgCalc.java
	Purpose:		This project calculates and displays
					the monthly payment amount to fully
					amortize a $200,000.00 loan over a 30
					year term at 5.75% interest.
*/

public class MtgCalc1
{
	public static void main(String[] args)
	{

		// Declare and build variables
		int LoanAmt=200000;
		int LoanTrm=360;
		double Interest=.0575;
		double MonthlyPmt=0;

		// Display mortgage calculator
		System.out.println("\t\t\tMortgage Calculator");
		System.out.println("\t\t\tThe loan amount is $200,000");
		System.out.println("\t\t\tThe term of the loan is 30 years");
		System.out.println("\t\t\tThe interest rate is 5.75%");
		System.out.println();

		// Declare formula
		MonthlyPmt=(LoanAmt*(Interest/12))/(1-1/Math.pow((1+Interest/12), LoanTrm));

		System.out.println("\t\t\tThe monthly payment is: $"+MonthlyPmt);
		System.out.println();

	}
}



Pony

Is This A Good Question/Topic? 0
  • +

Replies To: Decimal places

#2 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: Decimal places

Posted 12 June 2007 - 09:18 PM

Hi, I'm sure if look around this very java forum you can find what you are looking for. You can use the DecimalFormat class, here is a link that I just googled link
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1