473,383 Members | 1,821 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,383 software developers and data experts.

Mortgage Calculation Program

I'm trying to get this program to calualte the totals of 3 different mortgages using arrays.I need the program to calculate the loans to the end of each term. Can someone point me in the right direction, before I lose my mind!



Expand|Select|Wrap|Line Numbers
  1.  import java.math.*; 
  2. import java.text.DecimalFormat;
  3. import java.util.*;
  4.  
  5. public class mortgage3Loanswk5
  6. {
  7.     public static void main(String[]args)
  8.     {
  9.  
  10.     //Declare varibles//
  11.     double mortgage1, mortgage2, mortgage3, ammount;
  12.     ammount= 200000;//Principle loan//
  13.     double monthlyRate1, monthlyRate2, monthlyRate3;
  14. double[] iRate= {0.0575, 0.0550, 0.0535};//interest rates on 3 loans//
  15.     int[] term= {30, 15, 7};//number of years for loans//
  16.     double MP=(0);
  17.     int year= (0);
  18.     int month= (0);
  19.     int NewInterest1= (0);
  20.     int NewInterest2= (0);
  21.     int NewInterest3= (0);
  22.     int amount1= 200000;
  23.     int amount2= 200000;
  24.     int amount3= 200000;
  25.     double interest1= 0.0575;
  26.     double interest2= 0.055;
  27.     double interest3= 0.0535;
  28.     double []payment={(monthlyRate1), (monthlyRate2), (monthlyRate3)};
  29.     double []interest={(interest1), (interest2), (interest3)}; 
  30.  
  31.     String hold="";
  32.     Scanner scan=new Scanner(System.in);
  33.  
  34.  
  35.     DecimalFormat decimalPlaces=new DecimalFormat("0.00");
  36.     //Formulas used within this program//
  37.     monthlyRate1=(ammount*((iRate[0]/12)/(1-Math.pow((1+(iRate[0]/12)),-(term[0]*12)))));
  38.     interest1= amount1*(interest1/12);
  39.     loanamount1=(interest1+amount1)-(monthlyRate1));
  40.  
  41.     monthlyRate2=(ammount*((iRate[1]/12)/(1-Math.pow((1+(iRate[1]/12)),-(term[1]*12)))));
  42.     loanamount2=((interest2+amount2)-monthlyRate2);
  43.     interest2=(amount2*(interest2/12));
  44.  
  45.     monthlyRate3=(ammount*((iRate[2]/12)/(1-Math.pow((1+(iRate[2]/12)),-(term[2]*12)))));
  46.     interest3=(amount3*(interest3/12));
  47.     loanamount3=((interest3+amount3)-monthlyRate3);
  48.  
  49.     double []newmonthly={(loanamount1), (loanamount2), (loanamount3)};
  50.  
  51.     //loop begins here// 
  52.  
  53.     for(year=1; year<=term[0]; year++)
  54.     {
  55.     System.out.println();
  56.     System.out.println("Press\"Enter\"to continue.");
  57.     hold=scan.nextLine();
  58.  
  59.  
  60.     {
  61.  
  62.     }
  63.         }    
  64.  
  65. System.out.println("The interest of the loan is: "+iRate[0]*100+"%");    
  66. System.out.println("Monthly Payments for the 1st is:$" +decimalPlaces.format(monthlyRate1));
  67. System.out.println("The term of the loan is:"+term[0]+"years{"+term[0]*12+"months}");
  68. System.out.println("");
  69. System.out.println("The interest of the loan is: "+iRate[1]*100+"%");
  70. System.out.println("Monthly Payments for the 2nd loan is:$" +decimalPlaces.format(monthlyRate2));
  71. System.out.println("The term of the loan is:"+term[1]+"years{"+term[1]*12+"months}");
  72. System.out.println("");
  73. System.out.println("The interest of the loan is: "+iRate[2]*100+"%");
  74. System.out.println("Monthly Payments for the 3rd loan is:$" +decimalPlaces.format(monthlyRate2));
  75. System.out.println("The term of the loan is:"+term[2]+"years{"+term[2]*12+"months}");
  76. System.out.println("");
  77. }
  78.  
  79.  
  80.  
  81. }//End program//
  82.  
Mar 1 '07 #1
3 2563
r035198x
13,262 8TB
I'm trying to get this program to calualte the totals of 3 different mortgages using arrays.I need the program to calculate the loans to the end of each term. Can someone point me in the right direction, before I lose my mind!



Expand|Select|Wrap|Line Numbers
  1.  import java.math.*; 
  2. import java.text.DecimalFormat;
  3. import java.util.*;
  4.  
  5. public class mortgage3Loanswk5
  6. {
  7.     public static void main(String[]args)
  8.     {
  9.  
  10.     //Declare varibles//
  11.     double mortgage1, mortgage2, mortgage3, ammount;
  12.     ammount= 200000;//Principle loan//
  13.     double monthlyRate1, monthlyRate2, monthlyRate3;
  14. double[] iRate= {0.0575, 0.0550, 0.0535};//interest rates on 3 loans//
  15.     int[] term= {30, 15, 7};//number of years for loans//
  16.     double MP=(0);
  17.     int year= (0);
  18.     int month= (0);
  19.     int NewInterest1= (0);
  20.     int NewInterest2= (0);
  21.     int NewInterest3= (0);
  22.     int amount1= 200000;
  23.     int amount2= 200000;
  24.     int amount3= 200000;
  25.     double interest1= 0.0575;
  26.     double interest2= 0.055;
  27.     double interest3= 0.0535;
  28.     double []payment={(monthlyRate1), (monthlyRate2), (monthlyRate3)};
  29.     double []interest={(interest1), (interest2), (interest3)}; 
  30.  
  31.     String hold="";
  32.     Scanner scan=new Scanner(System.in);
  33.  
  34.  
  35.     DecimalFormat decimalPlaces=new DecimalFormat("0.00");
  36.     //Formulas used within this program//
  37.     monthlyRate1=(ammount*((iRate[0]/12)/(1-Math.pow((1+(iRate[0]/12)),-(term[0]*12)))));
  38.     interest1= amount1*(interest1/12);
  39.     loanamount1=(interest1+amount1)-(monthlyRate1));
  40.  
  41.     monthlyRate2=(ammount*((iRate[1]/12)/(1-Math.pow((1+(iRate[1]/12)),-(term[1]*12)))));
  42.     loanamount2=((interest2+amount2)-monthlyRate2);
  43.     interest2=(amount2*(interest2/12));
  44.  
  45.     monthlyRate3=(ammount*((iRate[2]/12)/(1-Math.pow((1+(iRate[2]/12)),-(term[2]*12)))));
  46.     interest3=(amount3*(interest3/12));
  47.     loanamount3=((interest3+amount3)-monthlyRate3);
  48.  
  49.     double []newmonthly={(loanamount1), (loanamount2), (loanamount3)};
  50.  
  51.     //loop begins here// 
  52.  
  53.     for(year=1; year<=term[0]; year++)
  54.     {
  55.     System.out.println();
  56.     System.out.println("Press\"Enter\"to continue.");
  57.     hold=scan.nextLine();
  58.  
  59.  
  60.     {
  61.  
  62.     }
  63.         }    
  64.  
  65. System.out.println("The interest of the loan is: "+iRate[0]*100+"%");    
  66. System.out.println("Monthly Payments for the 1st is:$" +decimalPlaces.format(monthlyRate1));
  67. System.out.println("The term of the loan is:"+term[0]+"years{"+term[0]*12+"months}");
  68. System.out.println("");
  69. System.out.println("The interest of the loan is: "+iRate[1]*100+"%");
  70. System.out.println("Monthly Payments for the 2nd loan is:$" +decimalPlaces.format(monthlyRate2));
  71. System.out.println("The term of the loan is:"+term[1]+"years{"+term[1]*12+"months}");
  72. System.out.println("");
  73. System.out.println("The interest of the loan is: "+iRate[2]*100+"%");
  74. System.out.println("Monthly Payments for the 3rd loan is:$" +decimalPlaces.format(monthlyRate2));
  75. System.out.println("The term of the loan is:"+term[2]+"years{"+term[2]*12+"months}");
  76. System.out.println("");
  77. }
  78.  
  79.  
  80.  
  81. }//End program//
  82.  
Explain what you have done and what you now need help with.
Mar 1 '07 #2
Well what I have done is created a program that displays the monthly cost for 3 different loans. Using the same principle, but different interest rates and number of years. So now I'm trying to figure out how to make it calculate the mortgages through the life of each loan using the same arrays and a for loop. So basically I need all the loans to be zeroed out at the end of each loan term.
Mar 1 '07 #3
DeMan
1,806 1GB
Not necessatrily in good java (and I'm not sure whether answering the question but...).....
Expand|Select|Wrap|Line Numbers
  1. int month = 0;
  2. int originalTot = loanAmount;
  3. while(loanAmount < monthlyAmount)
  4. {
  5.   loanAmount = loanAmount - monthlyAmount;
  6.   month ++
  7. }
  8. System.out.println("The loan of " +originalTot + "was paid off in " + (month+1) + " months, with a final payment of " + loanAmount");
  9.  
Mar 1 '07 #4

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

Similar topics

4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
4
by: promiscuoustx | last post by:
The problem is that my code below used to run wonderfully, until the instructor decided that he wants to use characters instead of integers, and wants my code to trap the bad and have the program...
3
by: promiscuoustx | last post by:
I am trying to get my program to compile, but it will not complete. At line 79 it states, cannot convert 'float()()' to 'float' in assignment. Here is my code. #include <iostream> #include...
3
by: cameron | last post by:
Hi I am new here in this forum: I am writing a C++ program to calculate a Montly Mortgage Payment where the loan amount is 200,000.00 with a 5.75% interest rate with a term of 30 years. My program...
2
by: phjones | last post by:
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...
1
by: phjones | last post by:
please help resolve some error messages code is compling with errors see below the code. I am new at this please help! /** * @(#)3 Mortgage loans.java * * 3 Mortgage loans application * ...
1
by: phjones | last post by:
This is not a class project.The program below is to display mortgage interest paid for each payment over the term of the loan and loan balance.It is program using array. However, I am receiving the...
1
by: dylbin | last post by:
I am having trouble with the following program: Without using a G.U.I., using a loan amount of $200,000 with an interest rate of 5.75% and a 30 year term, I have to display the mortgage payment...
3
by: zaidalin79 | last post by:
I have finally gotten my GUI to look like I want it to, but I am having trouble getting the calculations right. No matter what I put in there, it seems to calculate a large payment, and a very wrong...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.