Results 1 to 6 of 6
Thread: Illegal start of expression
- 03-11-2011, 12:02 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
Illegal start of expression
Hi
I'am adding the method printBMI to a class with the following code:
public void drukBMI()
{
double result;
result = (weight/height**2);
System.out.println ( "This person's BMI is" + result );
}
but when I compile he selects the line result = .....
"illegal start of expression"
how do I fix it?
- 03-11-2011, 12:24 PM #2
I think the problem is you have two multiplying characters after the other.
Sorry, I only speak machine language. Yes or a No?:confused:
- 03-11-2011, 12:28 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
Isn't it the same as height*height?
- 03-11-2011, 12:35 PM #4
No, you can use the Math class.
weight/Math.pow(height,2)
The pow method from the Math class is used to get height to the power of 2 which is the same as (height * height).Sorry, I only speak machine language. Yes or a No?:confused:
- 03-11-2011, 12:40 PM #5
I think height*=height would give the correct answer as well.
Sorry, I only speak machine language. Yes or a No?:confused:
- 03-11-2011, 12:42 PM #6
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Illegal start of expression
By Tekila in forum New To JavaReplies: 10Last Post: 03-04-2011, 12:23 AM -
illegal start of expression
By rajivjoshi in forum New To JavaReplies: 3Last Post: 05-31-2010, 09:12 AM -
Illegal Start of expression
By Macca07 in forum New To JavaReplies: 3Last Post: 11-23-2009, 08:43 AM -
Illegal start of expression
By Basit56 in forum New To JavaReplies: 2Last Post: 08-18-2009, 09:12 AM -
Illegal start of expression
By gabriel in forum New To JavaReplies: 2Last Post: 08-01-2007, 05:09 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks