# expected "(" error,

Page 1 of 1

## 3 Replies - 797 Views - Last Post: 13 April 2010 - 05:13 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=167693&amp;s=4468d806afd0ade702df2866b3c4d63c&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 HDRStudent

Reputation: 0
• Posts: 2
• Joined: 12-April 10

# expected "(" error,

Posted 12 April 2010 - 05:37 PM

My program is getting a error I can not figure out:

```public class mortCalcSR1
{
public static void main (String[] args)throws InterruptedException
{

double loanAmount = 200000;//The principal amount of the loan//
int term = 30;//The terms of the loan in years//
double interest =.0575;//The interest rate on the loan//
double monthlyPayment; //The monthly payment of the loan//
double currentPrincBalance=0;//This is the current balance of the principal only //

monthlyPayment=(loanAmount*(interest/12))/(1-(Math.pow(1/(1+interest/12),(term*12))));//Calculates the interest rate.//

System.out.println("Monthly Payment is \$"+ monthlyPayment);//Prints the monthy payment//
//Change request #1//
double loanBalance=0;//variable holding the loan balance//
double InterestPaid=0;//variable holding the interest paid on the loan//
int lineCount=0;//variable holding the counting of the lines//

while loanBalance=(loanAmount-monthlyPayment);//takes the laon amount and subtracts the monthly payment//
interestPaid=(monthlyPayment*interest);//this calculates the monthly interest//
{
if (loanBalance <=0){ //if the laons balance is less than zero the following will print//
System.out.println("Congratulations, you now own your home!");//prints the the loan has been apis off//
}
if (loanBalance>0){//if the laons balance is more than zero, the following will print//
System.out.println("Loan balance is \$"+loanBalance);//displays the loan balance//
System.out.println("Your accumulated interest paid is"+interestPaid);//displays the interest that has been paid on the loan//
}
if(lineCount=30){//counts the lines up to 30 each interval//
throw InterrupedException;//allows for interruption//
}

}
}
}

```

I am getting the following error:
C:\Users\Public\Documents\AXIA\Java\mortCalcSR1.java:21: '(' expected
while loanBalance=(loanAmount-monthlyPayment);//takes the laon amount and subtracts the monthly payment//
^
C:\Users\Public\Documents\AXIA\Java\mortCalcSR1.java:21: ')' expected
while loanBalance=(loanAmount-monthlyPayment);//takes the laon amount and subtracts the monthly payment//
^
2 errors

Tool completed with exit code 1

Can you help me understand why? I have been trying to fix this for three days and am at a loss. I have tried every form of using the ")" and nothing seems to work. I need advice from a programmer. Thank you kindly for your help.

Is This A Good Question/Topic? 0

## Replies To: expected "(" error,

### #2 KYA

• Wubba lubba dub dub!

Reputation: 3202
• Posts: 19,232
• Joined: 14-September 07

## Re: expected "(" error,

Posted 12 April 2010 - 05:38 PM

You need to have parentheses around the conditional in your while loop. also, get rid of the semicolon after it, the structure looks like this:

```while(condition){
//do this
}

```

You want to use '==' for equality comparison rather then '=' which is the assignment operator.

### #3 HDRStudent

Reputation: 0
• Posts: 2
• Joined: 12-April 10

## Re: expected "(" error,

Posted 12 April 2010 - 11:35 PM

I'll try that, thank you so much for the reply. I really appreciate you taking the time to help me.
Heather

### #4 japanir

• jaVanir

Reputation: 1014
• Posts: 3,025
• Joined: 20-August 09

## Re: expected "(" error,

Posted 13 April 2010 - 05:13 AM

In addition to what KYA said, the way you write your while statement, you should not have semicolons after the while loop as you have here, so you should remove them:
```while (loanBalance == (loanAmount-monthlyPayment);//<<these semicolon
```

also, the curly braces should be right after the condition, not as you have here to enclose all the code you want to execute in the while loop, so:
```while (loanBalance=(loanAmount-monthlyPayment){//<<<curly braces should start here
interestPaid=(monthlyPayment*interest);
{///<<these should be moved
```