Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 209

# array

My compiler is saying a ) is missing on my equation.it appears to be there. is something wrong?

import java.io.*;
import java.text.DecimalFormat;

class MortgageWeek4
{

public static void main(String arguments[])
{
/*Declaring Program Variables*/
double interestRate = 0.0575;//*Interest rate
double principal = 200000.00;//*Amount of Loan
double monthlyInterest = interestRate/12; //*Monthly interest
int periods = 360; //* 30 yrs @12 months each year is 360 months
double balance = principal;
double monthlyPrincipal;
DecimalFormat df = new DecimalFormat("\$#,###.00");
//Create new decimal format object that has the format required for this program
double mortgageRate[] = {.0535,.0550,.0575};
int payments[] = {84,180,360};

double mortgage=(principal*(mortgageRate[i]/12)/(1-(Math.pow(1/(1+mortgageRate[i]/12)),(payments[i]*12))));

int lines = 0;

for(int i=0; i < 3; i++) {

System.out.println((i+1) + "\t\t\t" + df.format(mortgageRate[i]) +
"\t\t" + df.format(payments[i]) +
"\t\t" + df.format(mortgage));

}
}
}
0
pgmtkl
• 2
• 2
1 Solution

Commented:
try:

class MortgageWeek4
{

public static void main(String arguments[])
{
/*Declaring Program Variables*/
double interestRate = 0.0575;//*Interest rate
double principal = 200000.00;//*Amount of Loan
double monthlyInterest = interestRate/12; //*Monthly interest
int periods = 360; //* 30 yrs @12 months each year is 360 months
double balance = principal;
double monthlyPrincipal;
DecimalFormat df = new DecimalFormat("\$#,###.00");
//Create new decimal format object that has the format required for this program
double mortgageRate[] = {.0535,.0550,.0575};
int payments[] = {84,180,360};

int lines = 0;

for(int i=0; i < 3; i++) {

double mortgage=(principal*(mortgageRate[i]/12)/(1-(Math.pow(1/(1+mortgageRate[i]/12), (payments[i]*12)))));
System.out.println((i+1) + "\t\t\t" + df.format(mortgageRate[i]) +
"\t\t" + df.format(payments[i]) +
"\t\t" + df.format(mortgage));

}
}
}
0

Author Commented:
Thank you. that works. The mortgage rate is correct, displaying as .0535. Is there a way i could displaying it as 5.35%?
0

Commented:
try:

NumberFormat.getPercentInstance().format(mortgageRate[i])
0

Author Commented:
Thank you.
0

## Featured Post

• 2
• 2
Tackle projects and never again get stuck behind a technical roadblock.