1. Member
Join Date
May 2011
Posts
29
Rep Power
0

## "illegal start of expression" killing me help please.

I haven't finished my program but i tried to compile it and i can't seem to figure out why I'm getting "illegal start of expression" at the end of my program for a method that i made called 'areaFORMULA'. Thanks in advance.

Java Code:
```import java.util.*;
public class FinalProject
{public static void main(String[] args)
{int a, b, c;
System.out.println("Enter the length of side \"a\" of the triangle to begin:");
Scanner in=new Scanner(System.in);
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();

if(a==0)
{System.exit(0);
}
while(a!=0)
{areaFORMULA();
perimeter();

if(a==b==c)
{System.out.print("According to the given sides, since a,b and c are equal ");
System.out.print("the triangle is an Equilateral triangle with an Area of "+area+" and Perimeter of "+p);
}
if(a==b||a==c||b==c)
{System.out.print("According to the given sides, since two sides are equal ");
System.out.print("the triangle is an Isosceles triangle with an Area of "+area+" and Perimeter of "+p);
}
if(a!=b!=c)
{System.out.print("According to the given sides, since a,b and c are not equal ");
System.out.print("the triangle is a Scalene triangle with an Area of "+area+" and Perimeter of "+p);
}
}
public static void areaFORMULA()
{double s = 0.5 * (a + b + c);
double area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
}

public static void perimeter()
{p = a+b+c;
}
}
}
}```

2. You style (indentation, bracket placement etc) sucks the big one! It makes your code very hard to read. The most likely causes of your problem is that you have a method inside another method, method inside an if or while. Basically your brackets do not match or out of order. If your style was more consistent it would be easier to see where the problem is.

3. Java Code:
```    if(a!=b!=c) {
System.out.print("According to th....
System.out.print("the triangle ....
} // end of if
} // end of while

public static void areaFORMULA() // inside main method```
As I suspected.

4. Member
Join Date
May 2011
Posts
29
Rep Power
0
Lol this isn't my usual style i wanted to try something different but it really screwed me up i changed everything back to the way i usually use my brackets and indentation. Thanks for your help.

5. Apart from your brackets and indentation there are so many other problems as well.

Like variables scopes, variable declaration, if statement conditions etc etc... Try to resolve them as well.

Goldest

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•