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

• 05-27-2011, 07:40 AM
Taszk
"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.

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;                 }         } } }```
• 05-27-2011, 07:46 AM
Junky
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.
• 05-27-2011, 07:48 AM
Junky
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.
• 05-27-2011, 08:15 AM
Taszk
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.
• 05-27-2011, 08:21 AM
goldest
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