473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

java mortgage calcuator using array for 3 different loan

Need help programming mortagage calculator for 3 different loans 7 year, 15 year and 30 year. using java array I am a beginner with Java, This is what I have so far. Need to know if I am off the path,

import java.math.*;//*loan calculator
import java.text.*;//*formats numbers
public class 3 Mortgage loans {


// declare class variable array
int[] mortgage calculator

//construct the array
mortgage calculator = new int[17];

Expand|Select|Wrap|Line Numbers
  1.     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • double loan = 200000
  •             double term1 =360//*360 month for 30 year mortgage
  •             double interRate1 = 0.0575; //*5.75% 5.75/100interest rate 30year mortgage
  •              double monthlyRate1 = (interestRate1/12)
  •             double term2 = 84//*7year mortgage loan
  •             double interestRate2 = 0.0535;//*5.35 5.35/100 interest rate 7 year mortgage
  •             double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan
  •             double term3 = 180 
  •  
  •     
  •  
  •  // 15 year mortgage
  •             double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage
  •             double monthlyRate3 = (interestRate3/12);//* monthlyRate for 15 year mortgage
  •  
  •             //Discount factr calculator for the three loans
  •             double discountFactor1 = (Math.pow ((1 + monthlyRate1),
  •             term1)-1/(monthlyRate1 * Math.pow((1 + monthlyRate1),term1));
  •  
  •             double discountFactor2 = (Math.pow((1  + monthlyRate2),term2)-1/
  •             (monthlyRate2* Math.pow((1 + monthlyRate2),term2));
  •  
  •             double discountFactor3 = (Math.pow((1 + monthlyRate3), term3) - 1)/
  •             (monthlyRate3 * Math.pow((1 + monthlyRate3), term3));
  •  
  •             double payment1 = loan/discountFactor1; //*Rate Calcualtion for 30 yearn mortgage
  •             double payment2 = loan/discountFactor2; //*Rate Calculaion for 7 year morgage
  •             double payment3 = loan/discountFactor3; //*Rate Clculation for 15 year mortgage
  •  
  • Dec 7 '06 #1
    2 7852
    r035198x
    13,262 8TB
    Need help programming mortagage calculator for 3 different loans 7 year, 15 year and 30 year. using java array I am a beginner with Java, This is what I have so far. Need to know if I am off the path,

    import java.math.*;//*loan calculator
    import java.text.*;//*formats numbers
    public class 3 Mortgage loans {


    // declare class variable array
    int[] mortgage calculator

    //construct the array
    mortgage calculator = new int[17];

    Expand|Select|Wrap|Line Numbers
    1.     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • double loan = 200000
  •             double term1 =360//*360 month for 30 year mortgage
  •             double interRate1 = 0.0575; //*5.75% 5.75/100interest rate 30year mortgage
  •             double monthlyRate1 = (interestRate1/12)
  •             double term2 = 84//*7year mortgage loan
  •             double interestRate2 = 0.0535;//*5.35 5.35/100 interest rate 7 year mortgage
  •             double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan
  •             double term3 = 180 
  •  
  •     
  •  
  •  // 15 year mortgage
  •             double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage
  •             double monthlyRate3 = (interestRate3/12);//* monthlyRate for 15 year mortgage
  •  
  •             //Discount factr calculator for the three loans
  •             double discountFactor1 = (Math.pow ((1 + monthlyRate1),
  •             term1)-1/(monthlyRate1 * Math.pow((1 + monthlyRate1),term1));
  •  
  •             double discountFactor2 = (Math.pow((1 + monthlyRate2),term2)-1/
  •             (monthlyRate2* Math.pow((1 + monthlyRate2),term2));
  •  
  •             double discountFactor3 = (Math.pow((1 + monthlyRate3), term3) - 1)/
  •             (monthlyRate3 * Math.pow((1 + monthlyRate3), term3));
  •  
  •             double payment1 = loan/discountFactor1; //*Rate Calcualtion for 30 yearn mortgage
  •             double payment2 = loan/discountFactor2; //*Rate Calculaion for 7 year morgage
  •             double payment3 = loan/discountFactor3; //*Rate Clculation for 15 year mortgage
  •  
  • use public class MortgageLoans as the class name. The one you have is invalid.
    You should define 3 arrays of type double not one of type int
    You will also need a loop to calculate the monthly repayments amounts.
    Make the above corrections and post the code
    Dec 7 '06 #2
    Unfortunately. This maybe a second posting. I sorry just getting started with this chat area. See new code below:

    /**
    * @(#)3 Mortgage loans.java
    *
    * 3 Mortgage loans application
    *
    * Phyllis J Jones
    * Purpose to write a program in Java without a graphical user interface and have
    it calculate the payment amount for 3 mortgage loans.
    */
    import java.math.*;//*loan calculator
    import java.text.*;//*formats numbers
    public class MortgageLoans {



    // declare class variable array
    double mortgage calculator1[];
    double mortgage calculator2[];
    double mortgage calculator3[];
    //construct the array
    mortgage calculator1 = new double[6];
    mortgage calculator2 = new double[6];
    mortgage calculator3 = new double[6];


    double loan = 200000
    double term1 =360//*360 month for 30 year mortgage
    double interRate1 = 0.0575; //*5.75% 5.75/100interest rate 30year mortgage
    double monthlyRate1 = (interestRate1/12)
    double term2 = 84//*7year mortgage loan
    double interestRate2 = 0.0535;//*5.35 5.35/100 interest rate 7 year mortgage
    double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan
    double term3 = 180 // 15 year mortgage
    double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage
    double monthlyRate3 = (interestRate3/12);//* monthlyRate for 15 year mortgage

    //Discount factr calculator for the three loans
    double discountFactor1 = (Math.pow ((1 + monthlyRate1),
    term1)-1/(monthlyRate1 * Math.pow((1 + monthlyRate1),term1));

    double discountFactor2 = (Math.pow((1 + monthlyRate2),term2)-1/
    (monthlyRate2* Math.pow((1 + monthlyRate2),term2));

    double discountFactor3 = (Math.pow((1 + monthlyRate3), term3) - 1)/
    (monthlyRate3 * Math.pow((1 + monthlyRate3), term3));

    double payment1 = loan/discountFactor1; //*Rate Calcualtion for 30 yearn mortgage
    double payment2 = loan/discountFactor2; //*Rate Calculaion for 7 year morgage
    double payment3 = loan/discountFactor3; //*Rate Clculation for 15 year mortgage



    //loop While not done
    while(loan > 0)
    {

    java.text.DecimalFormat dfm = new java.text.DecimalFormat(",###.00");
    System.out.println("Your monthly payment is $" + dfm.format(payment)+ "cemts");
    // loop while done
    if(loan>0)
    {
    double payment1 = loan/discountFactor1;//*Rate Calculation
    double payment2 = loan/discountFactor2;//*Rate Calculation
    double payment3 = loan/duiscountFactor3;//*Rate Calculation
    }
    else
    payment1 = payment/discountFactor1;//Rate Calculation
    payment2 = payment/discountFactor2;//Rate Calcuklation
    payment3 = payment/discountfactor3;//Rate Calculation
    }
    //Output

    }

    }
    Dec 8 '06 #3

    Sign in to post your reply or Sign up for a free account.

    Similar topics

    1
    by: Rvenkatesh | last post by:
    How to use array string in C#.Net to compare and replace characters between strings using function.
    2
    by: Matt | last post by:
    I'm new to Java but experienced with PL/SQL. I've found what appears to be strange behaviour (a bug?) when attempting to create java stored objects using the UNIX version of Oracle SQL*PLUS...
    0
    by: Sebastian Fey | last post by:
    hi, im looking for a way to paramterize a xml document. ive a documentation in docbook-xml and want to transform it using two different sets of entities. (resulting documents just differ in...
    1
    by: nel | last post by:
    hi.. i want to know how to insert data using array in mysql where the data stored in field given? this field_name i taken from database.... thanks a lot...
    2
    by: palani12kumar | last post by:
    Hi i've implemented a linear Queue using array. But i've been struck up with a doubt!!!!! Let me tell my problem with an example so that it can be clear. Size of the Queue(array) is 5. im...
    1
    by: aliag | last post by:
    HI I am trying to clal a java webservice (JWS) using java script but i keep on getting a "undefined" value calling a .NET webservices works fine using the webservice.htc file but i cant get the...
    1
    shoonya
    by: shoonya | last post by:
    i am using array as a data type in my db .... ( sequence integer ) ; and it stores a value let {1,2,3,4,5}
    2
    by: berrylthird | last post by:
    This question was inspired by scripting languages such as JavaScript. In JavaScript, I can access members of a class using array syntax as in the following example: var myInstance:myClass = new...
    0
    by: Charles Arthur | last post by:
    How do i turn on java script on a villaon, callus and itel keypad mobile phone
    0
    by: emmanuelkatto | last post by:
    Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
    0
    BarryA
    by: BarryA | last post by:
    What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
    1
    by: Sonnysonu | last post by:
    This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
    0
    by: Hystou | last post by:
    There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
    0
    Oralloy
    by: Oralloy | last post by:
    Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
    0
    tracyyun
    by: tracyyun | last post by:
    Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
    0
    agi2029
    by: agi2029 | last post by:
    Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
    0
    isladogs
    by: isladogs | last post by:
    The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

    By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

    To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.