# Mortgage Calculator

Page 1 of 1

## 5 Replies - 1877 Views - Last Post: 13 December 2008 - 05:01 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=76478&amp;s=4bcc60d2a37df292646c8ed36d4b9ecf&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 PhillyDiva1982

Reputation: 0
• Posts: 30
• Joined: 09-December 08

# Mortgage Calculator

Posted 12 December 2008 - 06:11 PM

What statement would be good for making a loan amortization table? Did I do this right so far?
```public class Week4_Mortgage {
public static void main(String []args)
{
//declare variables
double RateofLoan;
double TermofLoan;
double AmountofMortgage;
double MonthlyPayment;

Scanner input = new Scanner(System.in);
int userChoice = input.nextInt(); // returns the next integer

//Display decimal point format
DecimalFormat decimalPlaces=new DecimalFormat("0.00");

//Prompt user to choose the method to calculate the mortgage
Scanner input = new Scanner(System.in);
int userChoice = 0;

do  {
System.out.printIn("Please choose the method to use for the mortgage calculation");
userChoice = input.nextInt();

}

while(userChoice != 1 && userChoice != 2);

if (userChoice) == 1) {

//Display the first method
MonthlyPayment = (AmountofMortgage * InterestofLoan) / (1 - Math.pow(1 + InterestofLoan - TermofLoan));

}

else if (userChoice == 2) {

//Display the second method
MonthlyPayment = MonthlyPayment (InterestofLoan / (1 - Math.pow(1 + InterestofLoan) * - TermofLoan));

}

//Display calculation used for the mortgage calculation
MonthlyPayment = (AmountofMortgage * InterestofLoan) / (1 - Math.pow(1 + InterestofLoan - TermofLoan));

//Display the amount of each loan
TotalofLoan=JOptionPane.showInputDialog(null, "Enter the Amount of each Loan");
AmountofLoan = Double.parseDouble(TotalofLoan);

//Display interest rate
InterestofLoan=JOptionPane.showInputDialog(null, "Enter the Interest Rate in decimals");
LoanInterest = Double.parse.Double(InterestofLoan)*12;

//End of display interest rate

//Display loan term
MortgageTerm=JOptionPane.showInputDialog(null, "Enter the term of each loan");
TermofLoan = Integer.parseInt(MortgageTerm)*12;
```

Is This A Good Question/Topic? 0

## Replies To: Mortgage Calculator

### #2 Programmist

• Refactorer in Chief

Reputation: 255
• Posts: 1,843
• Joined: 02-January 06

## Re: Mortgage Calculator

Posted 13 December 2008 - 01:26 PM

This is probably the most common problem given to students every semester. Search this site for "mortgage calculator" and you'll see several threads to chose from.

This post has been edited by Programmist: 13 December 2008 - 01:26 PM

### #3 Ostralis

• #include <greeter>

Reputation: 9
• Posts: 562
• Joined: 13-December 08

## Re: Mortgage Calculator

Posted 13 December 2008 - 01:40 PM

So far looks pretty good. As Programmist said, there's probably a million topics like this.

As for your question, I just recently did this.

I created methods that determine the Loan and stuff, like getLoan(), etc., stuff like that.

Then, I called those methods in a voidmainstringarg, with utilization of the Scanner (I think thats java.util.* library).

So, I did mine differently, but what you have looks good so far.

### #4 Locke

• Sarcasm Extraordinaire!

Reputation: 550
• Posts: 5,624
• Joined: 20-March 08

## Re: Mortgage Calculator

Posted 13 December 2008 - 01:54 PM

Programmist, on 13 Dec, 2008 - 12:26 PM, said:

This is probably the most common problem given to students every semester. Search this site for "mortgage calculator" and you'll see several threads to chose from.

The drinking game has begun!

What kind of liquor?

This post has been edited by Locke37: 13 December 2008 - 01:55 PM

### #5 Programmist

• Refactorer in Chief

Reputation: 255
• Posts: 1,843
• Joined: 02-January 06

## Re: Mortgage Calculator

Posted 13 December 2008 - 02:56 PM

Damn. I guess I did say that I'd take a sip everytime someone said "mortgage calculator."

This post has been edited by Programmist: 13 December 2008 - 02:56 PM

### #6 Locke

• Sarcasm Extraordinaire!

Reputation: 550
• Posts: 5,624
• Joined: 20-March 08

## Re: Mortgage Calculator

Posted 13 December 2008 - 05:01 PM

Ah, but you did say the beginning of each semester. And as far as I know, it's the end of the semester for most people.