473,473 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Array-Mortgage Calculator

4 New Member
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 Software\JCreatorV4LE\MyProjects\mortgageloan\src\ mortgageloan.java:30: operator > cannot be applied to double[],int
while(balance >0)

C:\Program Files\Xinox Software\JCreatorV4LE\MyProjects\mortgageloan\src\ mortgageloan.java:33: operator * cannot be applied to double[],double[]
interest = discountfactor * balance;
^
C:\Program Files\Xinox Software\JCreatorV4LE\MyProjects\mortgageloan\src\ mortgageloan.java:34: operator - cannot be applied to double[],double
principal = monthlypayment - interest;
^
C:\Program Files\Xinox Software\JCreatorV4LE\MyProjects\mortgageloan\src\ mortgageloan.java:37: mortgagecalculator is already defined in amortize(double[],double[],double[],double[])
double [] mortgagecalculator = {200000,5.75,360,5.35,84,5.5,180};
^
C:\Program Files\Xinox Software\JCreatorV4LE\MyProjects\mortgageloan\src\ mortgageloan.java:61: cannot find symbol
symbol : method formqt(double)
location: class java.text.DecimalFormat
twoDigits.formqt(principal) + " \t\t\t " + twoDigits.format(interest)
^
C:\Program Files\Xinox Software\JCreatorV4LE\MyProjects\mortgageloan\src\ mortgageloan.java:66: operator - cannot be applied to double[],double
balance = balance - principal;// change the balance minus principal



Source code used to generate the 6 errors.

/**
* @(#)mortgageloan.java
*
* mortgageloan application
*
* @author
* @version 1.00 2006/12/8
*/




import java.math.*;//*loan calculator
import java.text.*;//*formats numbers
public class mortgageloan {

public static void amortize(double[] mortgagecalculator,double[] monthlypayment,
double[] balance, double[] discountfactor)
{

// Format for Output
DecimalFormat twoDigits = new DecimalFormat("$###,###.00");
// declare


double principal;
int num = 1;
double interest;

while(balance >0)
{
// calculate interest a it changes
interest = discountfactor * balance;
principal = monthlypayment - interest;

//array for mortgage information
double [] mortgagecalculator = {200000,5.75,360,5.35,84,5.5,180};

//Output declare new variable new java.text
java.text.DecimalFormat dfm = new java.text.DecimalFormat(",###.00");

// statment to format output
if(num <0)
{
System.out.println("\t\t\t\t" + num + ".\t\t\t\t" +
twoDigits.format(principal) + " \t\t\t " + twoDigits.format(interest) + "\t\t\t\t" + twoDigits.format(balance));
}
else if (num >=10 && num < 100)
{
System.out.println("\t\t\t " + num + ".\t\t\t\t" +
twoDigits.format(principal) + " \t\t\t " + twoDigits.format(interest) + "\t\t\t\t" + twoDigits.format(balance));
}
else if (num > 100 && num < 360)
{
System.out.println("\t\t\t " + num + ".\t\t\t\t" +
twoDigits.format(principal) + "\t\t\t" + twoDigits.format(interest) + "\t\t\t\t" + twoDigits.format(balance));
}
else
{
System.out.println("\t\t\t " + num + ".\t\t\t\t" +
twoDigits.formqt(principal) + " \t\t\t " + twoDigits.format(interest)
+ "\t\t\t "+ twoDigits.format(balance));
}
++num; //increments the variable num by 1.

balance = balance - principal;// change the balance minus principal
}
}










public static void main (String[] args){

// declare
double discountfactor;// Variable for interest
double monthlypayment; //Variable fo monthly payment


//array for mortgage information
double [] mortgagecalculator = {200000,5.75,360,5.35,84,5.5,180};

//Output declare new variable new java.text
java.text.DecimalFormat dfm = new java.text.DecimalFormat(",###.00");


//Discount factor calculator and payments for the three loans

discountfactor =(1+ (( mortgagecalculator[1]/100)/12));//discountfactor for 30year at 5.75
monthlypayment = mortgagecalculator[0] * ((discountfactor - 1) / (1 - Math.pow(discountfactor, - mortgagecalculator[2])));//calauclate mortgage for 30yeara at 5.75
System.out.println("Your monthly payment on the 30 year loan is $" + dfm.format(monthlypayment));

discountfactor = (1 + ((mortgagecalculator[3] /100)/12));//discountfactor for 7 year at 5.35
monthlypayment = mortgagecalculator[0] *((discountfactor - 1) / (1 - Math.pow(discountfactor, - mortgagecalculator[4]))); //calculate mortgage for 7 year at 5.35
System.out.println("Your monthly payment on the 7 year at 5.35 is $" + dfm.format(monthlypayment));

discountfactor = (1 + ((mortgagecalculator[5]/100)/12));//discountfactor for 15 year at 5.5
monthlypayment = mortgagecalculator[0] * ((discountfactor - 1) /(1 - Math.pow(discountfactor, - mortgagecalculator[6])));//calculate mortgage for 15 year at 5.5
System.out.println("Your monthly payment on the 15 year at 5.5 is $" + dfm.format(monthlypayment));









}

}
Dec 29 '06 #1
1 6822
bartonc
6,596 Recognized Expert Expert
I see that you had gotten help when you were working on this in Java.
Please read the posting guidelines (on the right while you are posting) to learn what CODE tags look like:
Expand|Select|Wrap|Line Numbers
  1. code should look like this
and try posting in the C++/C forum for help with this. Thanks.
Dec 31 '06 #2

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

Similar topics

2
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a...
15
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
8
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array(...
12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
8
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
7
by: Jim Carlock | last post by:
Looking for suggestions on how to handle bad words that might get passed in through $_GET variables. My first thoughts included using str_replace() to strip out such content, but then one ends...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
0
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...
0
jinu1996
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.