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! - import java.math.*;
-
import java.text.DecimalFormat;
-
import java.util.*;
-
-
public class mortgage3Loanswk5
-
{
-
public static void main(String[]args)
-
{
-
-
//Declare varibles//
-
double mortgage1, mortgage2, mortgage3, ammount;
-
ammount= 200000;//Principle loan//
-
double monthlyRate1, monthlyRate2, monthlyRate3;
-
double[] iRate= {0.0575, 0.0550, 0.0535};//interest rates on 3 loans//
-
int[] term= {30, 15, 7};//number of years for loans//
-
double MP=(0);
-
int year= (0);
-
int month= (0);
-
int NewInterest1= (0);
-
int NewInterest2= (0);
-
int NewInterest3= (0);
-
int amount1= 200000;
-
int amount2= 200000;
-
int amount3= 200000;
-
double interest1= 0.0575;
-
double interest2= 0.055;
-
double interest3= 0.0535;
-
double []payment={(monthlyRate1), (monthlyRate2), (monthlyRate3)};
-
double []interest={(interest1), (interest2), (interest3)};
-
-
String hold="";
-
Scanner scan=new Scanner(System.in);
-
-
-
DecimalFormat decimalPlaces=new DecimalFormat("0.00");
-
//Formulas used within this program//
-
monthlyRate1=(ammount*((iRate[0]/12)/(1-Math.pow((1+(iRate[0]/12)),-(term[0]*12)))));
-
interest1= amount1*(interest1/12);
-
loanamount1=(interest1+amount1)-(monthlyRate1));
-
-
monthlyRate2=(ammount*((iRate[1]/12)/(1-Math.pow((1+(iRate[1]/12)),-(term[1]*12)))));
-
loanamount2=((interest2+amount2)-monthlyRate2);
-
interest2=(amount2*(interest2/12));
-
-
monthlyRate3=(ammount*((iRate[2]/12)/(1-Math.pow((1+(iRate[2]/12)),-(term[2]*12)))));
-
interest3=(amount3*(interest3/12));
-
loanamount3=((interest3+amount3)-monthlyRate3);
-
-
double []newmonthly={(loanamount1), (loanamount2), (loanamount3)};
-
-
//loop begins here//
-
-
for(year=1; year<=term[0]; year++)
-
{
-
System.out.println();
-
System.out.println("Press\"Enter\"to continue.");
-
hold=scan.nextLine();
-
-
-
{
-
-
}
-
}
-
-
System.out.println("The interest of the loan is: "+iRate[0]*100+"%");
-
System.out.println("Monthly Payments for the 1st is:$" +decimalPlaces.format(monthlyRate1));
-
System.out.println("The term of the loan is:"+term[0]+"years{"+term[0]*12+"months}");
-
System.out.println("");
-
System.out.println("The interest of the loan is: "+iRate[1]*100+"%");
-
System.out.println("Monthly Payments for the 2nd loan is:$" +decimalPlaces.format(monthlyRate2));
-
System.out.println("The term of the loan is:"+term[1]+"years{"+term[1]*12+"months}");
-
System.out.println("");
-
System.out.println("The interest of the loan is: "+iRate[2]*100+"%");
-
System.out.println("Monthly Payments for the 3rd loan is:$" +decimalPlaces.format(monthlyRate2));
-
System.out.println("The term of the loan is:"+term[2]+"years{"+term[2]*12+"months}");
-
System.out.println("");
-
}
-
-
-
-
}//End program//
-
3 2580
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! - import java.math.*;
-
import java.text.DecimalFormat;
-
import java.util.*;
-
-
public class mortgage3Loanswk5
-
{
-
public static void main(String[]args)
-
{
-
-
//Declare varibles//
-
double mortgage1, mortgage2, mortgage3, ammount;
-
ammount= 200000;//Principle loan//
-
double monthlyRate1, monthlyRate2, monthlyRate3;
-
double[] iRate= {0.0575, 0.0550, 0.0535};//interest rates on 3 loans//
-
int[] term= {30, 15, 7};//number of years for loans//
-
double MP=(0);
-
int year= (0);
-
int month= (0);
-
int NewInterest1= (0);
-
int NewInterest2= (0);
-
int NewInterest3= (0);
-
int amount1= 200000;
-
int amount2= 200000;
-
int amount3= 200000;
-
double interest1= 0.0575;
-
double interest2= 0.055;
-
double interest3= 0.0535;
-
double []payment={(monthlyRate1), (monthlyRate2), (monthlyRate3)};
-
double []interest={(interest1), (interest2), (interest3)};
-
-
String hold="";
-
Scanner scan=new Scanner(System.in);
-
-
-
DecimalFormat decimalPlaces=new DecimalFormat("0.00");
-
//Formulas used within this program//
-
monthlyRate1=(ammount*((iRate[0]/12)/(1-Math.pow((1+(iRate[0]/12)),-(term[0]*12)))));
-
interest1= amount1*(interest1/12);
-
loanamount1=(interest1+amount1)-(monthlyRate1));
-
-
monthlyRate2=(ammount*((iRate[1]/12)/(1-Math.pow((1+(iRate[1]/12)),-(term[1]*12)))));
-
loanamount2=((interest2+amount2)-monthlyRate2);
-
interest2=(amount2*(interest2/12));
-
-
monthlyRate3=(ammount*((iRate[2]/12)/(1-Math.pow((1+(iRate[2]/12)),-(term[2]*12)))));
-
interest3=(amount3*(interest3/12));
-
loanamount3=((interest3+amount3)-monthlyRate3);
-
-
double []newmonthly={(loanamount1), (loanamount2), (loanamount3)};
-
-
//loop begins here//
-
-
for(year=1; year<=term[0]; year++)
-
{
-
System.out.println();
-
System.out.println("Press\"Enter\"to continue.");
-
hold=scan.nextLine();
-
-
-
{
-
-
}
-
}
-
-
System.out.println("The interest of the loan is: "+iRate[0]*100+"%");
-
System.out.println("Monthly Payments for the 1st is:$" +decimalPlaces.format(monthlyRate1));
-
System.out.println("The term of the loan is:"+term[0]+"years{"+term[0]*12+"months}");
-
System.out.println("");
-
System.out.println("The interest of the loan is: "+iRate[1]*100+"%");
-
System.out.println("Monthly Payments for the 2nd loan is:$" +decimalPlaces.format(monthlyRate2));
-
System.out.println("The term of the loan is:"+term[1]+"years{"+term[1]*12+"months}");
-
System.out.println("");
-
System.out.println("The interest of the loan is: "+iRate[2]*100+"%");
-
System.out.println("Monthly Payments for the 3rd loan is:$" +decimalPlaces.format(monthlyRate2));
-
System.out.println("The term of the loan is:"+term[2]+"years{"+term[2]*12+"months}");
-
System.out.println("");
-
}
-
-
-
-
}//End program//
-
Explain what you have done and what you now need help with.
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.
DeMan 1,806
Top Contributor
Not necessatrily in good java (and I'm not sure whether answering the question but...)..... -
int month = 0;
-
int originalTot = loanAmount;
-
while(loanAmount < monthlyAmount)
-
{
-
loanAmount = loanAmount - monthlyAmount;
-
month ++
-
}
-
System.out.println("The loan of " +originalTot + "was paid off in " + (month+1) + " months, with a final payment of " + loanAmount");
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 program is doing I show a window
which contains a progress bar and a label. At some point during the
execution the state of the calculation is changed,...
|
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 state that the user did not imput the correct values. Can someone help me figure out how to make my code work that way??? I have the majority of the...
|
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 <iomanip>
#include <cmath>
#include <cctype>
#include <stdlib.h>
#include <sstream>
using namespace std;
|
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 compiles fine with no errors but my calculation is not working correctly, any suggestions would be great as this assignment is due on Monday:...
|
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 path,
import java.math.*;//*loan calculator
import java.text.*;//*formats numbers
public class 3 Mortgage loans {
// declare class...
| |
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
*
* Phyllis J Jones
* Purpose to write a program in Java without a graphical user interface and have
|
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 following error message:
--------------------Configuration: <Default>--------------------
C:\Program Files\Xinox...
|
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 amount and then list the loan balance and interest paid for each payment over the term of the loan.
|
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 amortization schedule... Here is what I have so far...
package guiweek3;
//imports necessary tools
import java.io.*;
import java.awt.*;...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |