User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 401,653 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,681 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 8957 | Replies: 5
Reply
Join Date: Jan 2005
Posts: 5
Reputation: wardduncan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
wardduncan wardduncan is offline Offline
Newbie Poster

Help illegal start of expression

  #1  
Feb 3rd, 2005
I need some help with understanding an error that I am getting. Can anyone help me. Here is my problem. I am trying to hardcode information for a mortgage calc and I am getting an illegal start of expression error. Here is an example:

MortgageLoanCalculator.java:15: illegal start of expression
double interestRate = 5.7%; // Interest Rate = 5.75%

What does it mean?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Location: Pakistan
Posts: 1,673
Reputation: nanosani is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 50
Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: illegal start of expression

  #2  
Feb 3rd, 2005
Can you post the previous few lines of the code ... the problem could be in the previous lines too ... look at them.
Reply With Quote  
Join Date: Jan 2005
Posts: 5
Reputation: wardduncan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
wardduncan wardduncan is offline Offline
Newbie Poster

Re: illegal start of expression

  #3  
Feb 3rd, 2005
Sure. Here is the program.

public class MortgageLoanCalculator
{
//Main method
public static void main(String [] args)
{
double interestRate = 5.7%; int numberOfYears = 30;
double loanAmount = %200,00;

//Enter monthly interest rate
System.out.println("The interest rate is:" + interestRate);
System.out.println("The loan amount is:" + loanAmount);
System.out.println("The term in years is:" + numberOfYears);

}
}
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: illegal start of expression

  #4  
Feb 3rd, 2005
The % is a sign for modular division in java.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: illegal start of expression

  #5  
Feb 3rd, 2005
you might want to play around with the DecimalFormat class some, if you want your numbers to have commas after every three numbers and an % before or after your numbers.
Reply With Quote  
Join Date: Jul 2004
Location: Pakistan
Posts: 1,673
Reputation: nanosani is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 50
Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: illegal start of expression

  #6  
Feb 3rd, 2005
Try this out now
public class MortgageLoanCalculator
{
//Main method
public static void main(String [] args)
{
double interestRate = 5.7; // you are defining a double value .. and % is not a double.
int numberOfYears = 30;
double loanAmount = 20000; //java doesnt recognize comas in doubles.

//Enter monthly interest rate
System.out.println("The interest rate is:" + interestRate);
System.out.println("The loan amount is:" + loanAmount);
System.out.println("The term in years is:" + numberOfYears);

}
}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 6:54 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC