java code

mortage calculator trying to make the code to quit the program a

Page 1 of 1

2 Replies - 730 Views - Last Post: 09 April 2010 - 08:11 PM Rate Topic: -----

#1 Guest_raedefoor*


Reputation:

java code

Posted 09 April 2010 - 08:00 PM

import java.util.Scanner;
  
  public class MortgageCalc{
      public static void main(String args[]){
         Scanner LoanInfo = new Scanner (System.in);
  
  

        double LoanAmount, InterestRate, MonthlyPayment, LoanTotal, LoanDuration, InterestRatePerMonth, NumberofPayments;
  
 
         System.out.print("Mortgage Calc > Enter the Loan Ammount($): ");
             LoanAmount = LoanInfo.nextDouble();  //When information is entered it is stored as LoanAmount.
         System.out.print("Mortgage Calc > Enter the Loan Period (YRS): ");
             LoanDuration = LoanInfo.nextInt();  //When information is entered it is stored as LoanDuration.
         System.out.print("Mortgage Calc > Enter the Loan Interest Rate(%): ");
             InterestRate = LoanInfo.nextDouble();  //When information is entered it is stored as InterestRate.
 
         InterestRatePerMonth = (InterestRate/100)/12;  // Converts the entered number into a percentage then divides by 12 to get the interest rate per month.
         NumberofPayments = LoanDuration*12;           // Converts the LoanDuration in (yrs) to number of monthly payments.
 
         MonthlyPayment = LoanAmount*(Math.pow((1+InterestRatePerMonth), NumberofPayments))*InterestRatePerMonth/((Math.pow((1+InterestRatePerMonth),(NumberofPayments)))-1);

         //Calculation Used:  M = P[i(1+i)^n]/[(1+i)^n-1]
         // M = Monthly Payment, i = InterestRate/12 (for 12 months per year), n = Number of Payments (This is equivalent to LoanDuration * 12 months in a year)
         // P = LoanAmount
 
         System.out.println("");
         System.out.print("Mortgage Calc > Monthly Loan Payment($): ");
         System.out.print(Math.round(MonthlyPayment*100)/100f);  // Rounds the MonthlyPayment display to 2 decimal places.
	}

         //Variables Declared
	int	i=0,
		month;


This post has been edited by Dogstopper: 09 April 2010 - 08:11 PM
Reason for edit:: fixed code tags


Is This A Good Question/Topic? 0

Replies To: java code

#2 s3thst4   User is offline

  • a * a = (b * b) + (c * c) - 2(b)(c)cos(A)
  • member icon

Reputation: 10
  • View blog
  • Posts: 587
  • Joined: 20-November 08

Re: java code

Posted 09 April 2010 - 08:04 PM

1) Where are the code tags?

2) What's the problem? O_O
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: java code

Posted 09 April 2010 - 08:11 PM

Please, :code:
Also, please specifically describe the errors in the body of your post, not in the title where it gets truncated.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1