illegal start of expression

Reply

Join Date: Jan 2005
Posts: 5
Reputation: wardduncan is an unknown quantity at this point 
Solved Threads: 0
wardduncan wardduncan is offline Offline
Newbie Poster

illegal start of expression

 
0
  #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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: illegal start of expression

 
0
  #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 Quick reply to this message  
Join Date: Jan 2005
Posts: 5
Reputation: wardduncan is an unknown quantity at this point 
Solved Threads: 0
wardduncan wardduncan is offline Offline
Newbie Poster

Re: illegal start of expression

 
0
  #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 Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: illegal start of expression

 
0
  #4
Feb 3rd, 2005
The % is a sign for modular division in java.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: illegal start of expression

 
0
  #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 Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: illegal start of expression

 
0
  #6
Feb 3rd, 2005
Try this out now
  1. public class MortgageLoanCalculator
  2. {
  3. //Main method
  4. public static void main(String [] args)
  5. {
  6. double interestRate = 5.7; // you are defining a double value .. and % is not a double.
  7. int numberOfYears = 30;
  8. double loanAmount = 20000; //java doesnt recognize comas in doubles.
  9.  
  10. //Enter monthly interest rate
  11. System.out.println("The interest rate is:" + interestRate);
  12. System.out.println("The loan amount is:" + loanAmount);
  13. System.out.println("The term in years is:" + numberOfYears);
  14.  
  15. }
  16. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC