473,772 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ 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\JCreat orV4LE\MyProjec ts\mortgageloan \src\mortgagelo an.java:30: operator > cannot be applied to double[],int
while(balance >0)

C:\Program Files\Xinox Software\JCreat orV4LE\MyProjec ts\mortgageloan \src\mortgagelo an.java:33: operator * cannot be applied to double[],double[]
interest = discountfactor * balance;
^
C:\Program Files\Xinox Software\JCreat orV4LE\MyProjec ts\mortgageloan \src\mortgagelo an.java:34: operator - cannot be applied to double[],double
principal = monthlypayment - interest;
^
C:\Program Files\Xinox Software\JCreat orV4LE\MyProjec ts\mortgageloan \src\mortgagelo an.java:37: mortgagecalcula tor is already defined in amortize(double[],double[],double[],double[])
double [] mortgagecalcula tor = {200000,5.75,36 0,5.35,84,5.5,1 80};
^
C:\Program Files\Xinox Software\JCreat orV4LE\MyProjec ts\mortgageloan \src\mortgagelo an.java:61: cannot find symbol
symbol : method formqt(double)
location: class java.text.Decim alFormat
twoDigits.formq t(principal) + " \t\t\t " + twoDigits.forma t(interest)
^
C:\Program Files\Xinox Software\JCreat orV4LE\MyProjec ts\mortgageloan \src\mortgagelo an.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.

/**
* @(#)mortgageloa n.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[] mortgagecalcula tor,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 [] mortgagecalcula tor = {200000,5.75,36 0,5.35,84,5.5,1 80};

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

// statment to format output
if(num <0)
{
System.out.prin tln("\t\t\t\t" + num + ".\t\t\t\t" +
twoDigits.forma t(principal) + " \t\t\t " + twoDigits.forma t(interest) + "\t\t\t\t" + twoDigits.forma t(balance));
}
else if (num >=10 && num < 100)
{
System.out.prin tln("\t\t\t " + num + ".\t\t\t\t" +
twoDigits.forma t(principal) + " \t\t\t " + twoDigits.forma t(interest) + "\t\t\t\t" + twoDigits.forma t(balance));
}
else if (num > 100 && num < 360)
{
System.out.prin tln("\t\t\t " + num + ".\t\t\t\t" +
twoDigits.forma t(principal) + "\t\t\t" + twoDigits.forma t(interest) + "\t\t\t\t" + twoDigits.forma t(balance));
}
else
{
System.out.prin tln("\t\t\t " + num + ".\t\t\t\t" +
twoDigits.formq t(principal) + " \t\t\t " + twoDigits.forma t(interest)
+ "\t\t\t "+ twoDigits.forma t(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 [] mortgagecalcula tor = {200000,5.75,36 0,5.35,84,5.5,1 80};

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


//Discount factor calculator and payments for the three loans

discountfactor =(1+ (( mortgagecalcula tor[1]/100)/12));//discountfactor for 30year at 5.75
monthlypayment = mortgagecalcula tor[0] * ((discountfacto r - 1) / (1 - Math.pow(discou ntfactor, - mortgagecalcula tor[2])));//calauclate mortgage for 30yeara at 5.75
System.out.prin tln("Your monthly payment on the 30 year loan is $" + dfm.format(mont hlypayment));

discountfactor = (1 + ((mortgagecalcu lator[3] /100)/12));//discountfactor for 7 year at 5.35
monthlypayment = mortgagecalcula tor[0] *((discountfact or - 1) / (1 - Math.pow(discou ntfactor, - mortgagecalcula tor[4]))); //calculate mortgage for 7 year at 5.35
System.out.prin tln("Your monthly payment on the 7 year at 5.35 is $" + dfm.format(mont hlypayment));

discountfactor = (1 + ((mortgagecalcu lator[5]/100)/12));//discountfactor for 15 year at 5.5
monthlypayment = mortgagecalcula tor[0] * ((discountfacto r - 1) /(1 - Math.pow(discou ntfactor, - mortgagecalcula tor[6])));//calculate mortgage for 15 year at 5.5
System.out.prin tln("Your monthly payment on the 15 year at 5.5 is $" + dfm.format(mont hlypayment));









}

}
Dec 29 '06 #1
1 6842
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
2783
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
575
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 print_r cmd any suggestions would be great. Thanks much Todd //avShed array Array ( => Array ( => 1 => 08:00 ) => Array ( => 1 => 08:05 ) => Array ( => 1 => 08:10 ) => Array ( => 1 => 08:15 ) => Array ( => 1 => 08:20 ) => Array...
15
5193
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
3481
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( "name", "title", "reports to user id", "start date in the format: mm/dd/yyyy" ) ); How can I display this hierarchy in simple nested <li> tags in the most
12
55571
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 also removed) So far I have (val is value, ar is array, returns new array):
8
10232
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 it is assigned a text literal?? HOW can I change the array value to upper case then? What other method exists for arrays? Ex: var GridArrayName1 = new Array(); GridArrayName1 = new Array ('test-value'); GridArrayName1 = GridArrayName1...
58
10181
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 code... TCHAR myArray; DoStuff(myArray);
104
17008
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 that array Could you show me a little example how to do this? Thanks.
7
3199
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 up looking for characters that wrap around the stripped characters and it ends up as a recursive ordeal that fails to identify a poorly constructed $_GET variable (when someone hand-types the item into the line and makes a simple typing error).
17
7255
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 to show the array data to the end user. Can I do that? How?
0
10261
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6715
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.