JAVA Illegal Start of Expression Error

Reply

Join Date: Mar 2006
Posts: 2
Reputation: lrw0831 is an unknown quantity at this point 
Solved Threads: 0
lrw0831 lrw0831 is offline Offline
Newbie Poster

JAVA Illegal Start of Expression Error

 
0
  #1
Mar 26th, 2006
Could someone please help me out. I have an illegal start of an expression error at line 8 in the following code.

package untitled5;

public class Untitled1 {
public static void main(String[] args) {



public static void main(String[] args) {
int start_system, add_modify, add_modify_animal_data, report,
exit_system;
int check = menu();
while (check != 4) {
if (check == 1) {
add_modify_data();
}
else
if (check == 2) {
add_modify_medical_data();
}
else
if (check == 3) {
report();
}
check = menu();
}

exit_system();
System.exit(0);
}

{
public static void start_system() {
System.out.println("Start_system now");
}
}
//sets up the output
public static int menu() {
int check;
String output = "Modify Animal Data" + "\n " +
"1. Add/Modify Animal Data " + "\n" +
"2. Add/modify Meical Data " + "\n" +
"3. Report Section " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check = Integer.parseInt(scheck);
return check;
}
public static void add_modify() {
int check1;
while (check1 != 4) {
if (check1 == 1) {
add_animal_data();
}
else
if (check1 == 2) {
delete_animal_data();
}
else
if (check1 == 3) {
change_animal_data();

}
check1 = menu();

}
exit_system();
System.exit(0);
String output = "Modify Animal Data " + "\n " +
"1. Add Animal Data " + "\n" +
"2. Modify Animal Data " + "\n" +
"3. Change Animal Data " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check1 = Integer.parseInt(scheck);
}
public static void add_modify_medical_data() {
int check2;
while (check2 != 4) {
if (check2 == 1) {
add_medical();

}
else
if (check2 == 2) {
delete_medical();

}
else
if (check2 == 3) {
change_medical();

}
check2 = menu();

}
exit_system();
System.exit(0);
String output = "Modify Medical Data " + "\n " +
"1. Add Medical Data " + "\n" +
"2. Modify Medical Data " + "\n" +
"3. Change Change Data " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check2 = Integer.parseInt(scheck);
}
public static void report() {
System.out.println("in Report");
}
public static void exit_system() {
System.out.println("in exit system");
};

}
}




Thank you
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 216
Reputation: hooknc is an unknown quantity at this point 
Solved Threads: 8
hooknc hooknc is offline Offline
Posting Whiz in Training

Re: JAVA Illegal Start of Expression Error

 
0
  #2
Mar 26th, 2006
of course you do.

You're trying to declare a method inside of a method.

Remove the first public static void main method and then a ending } near the bottom of your code and that should help you out some.

Also, you have an extra ; at the end of your exit_system method.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 2
Reputation: lrw0831 is an unknown quantity at this point 
Solved Threads: 0
lrw0831 lrw0831 is offline Offline
Newbie Poster

Re: JAVA Illegal Start of Expression Error

 
0
  #3
Mar 26th, 2006
I am getting the same error message except now it is at line 29
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 216
Reputation: hooknc is an unknown quantity at this point 
Solved Threads: 8
hooknc hooknc is offline Offline
Posting Whiz in Training

Re: JAVA Illegal Start of Expression Error

 
0
  #4
Mar 27th, 2006
of course you are.

You really need to check your combination of open and close brackets. You must have an equal amout of both and you must fallow the java rules for declaration of attributes and methods.

I would recommend picking up a basic java book to learn these rules.

[offtopic]
Arn't the smiles here about the most evil things you've ever seen? The normal smile looks like he just took you for all you're worth.
[/offtopic]
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: JAVA Illegal Start of Expression Error

 
0
  #5
Mar 27th, 2006
Originally Posted by hooknc
of course you are.

You really need to check your combination of open and close brackets. You must have an equal amout of both and you must fallow the java rules for declaration of attributes and methods.

I would recommend picking up a basic java book to learn these rules.

[offtopic]
Arn't the smiles here about the most evil things you've ever seen? The normal smile looks like he just took you for all you're worth.
[/offtopic]
True it's more like a condescending smirk, I don't care tho... I like to antognise people...it's fun either way.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 9
Reputation: j3p0yz is an unknown quantity at this point 
Solved Threads: 0
j3p0yz j3p0yz is offline Offline
Newbie Poster

hi..

 
0
  #6
Jun 11th, 2007
hi can anyone help me please. I'm having problem with my program. It's only one error illegal starts of expression in public void check (), at line 53. What it is mean?..


import javax.swing.JOptionPane;
//public class waiter{
//public static void main(String [] args)
class waiter


{
private double tab;
public waiter(String name);
{
System.out.println("My name is "+ name +", and i'll be your waiter!");
tab = 0.0;
}
public double priceof(String s);
{
double price;
if (s.equals("Chicken"))
{price = 5.95;}
else
{//burger fries
if (s.equals("burger"))
{price = 4.95; }
else
{price = 1.95;}

}//burger or fries
return price;
}//priceof
public void order(String s)
{
if(s.equals("Chicken"))
{
tab = tab + 5.95;
}// burger fries
else
{//burger fries
if (s.equals("Burger"))
{
tab = tab + 4.95;
}
else
{
tab = tab + 1.95;
}
}//price of

public void check()
{
System.out.println("Please pay $" + tab+",null");
}

}//end of class waiter
public class objects3
{
public static void main(String [] args)
{
waiter ourwaiter;
ourwaiter = new waiter ("Manfred");// makes a waiter object
double x; //to hold price of burger
double y; //varikable to hold price of chicken
x = ourwaiter.priceof("burger");
y = ourwaiter.priceof("chicken");
if (x<y)// buy cheaper product
{
System.out.println("I'll take the burger because it's cheaper");
ourwaiter.order("Burger");
}//burger
else
{
System.out.println("I'll take the chicken. ");
ourwaiter.order("chicken");
}//chicekn
System.out.println("And i'll have fries with that");
ourwaiter.oreder("Fries");
System.out.println("\n eat eat....\n");

ourwaiter.check();
}//main
}//class objects3
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: JAVA Illegal Start of Expression Error

 
0
  #7
Jun 12th, 2007
use code tags if you want people to read your code.
And don't go hijacking other peoples' threads, not even old ones like this.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 9
Reputation: j3p0yz is an unknown quantity at this point 
Solved Threads: 0
j3p0yz j3p0yz is offline Offline
Newbie Poster

Re: JAVA Illegal Start of Expression Error

 
0
  #8
Jun 12th, 2007
i'm sory i don't know where to type my program. i'm very sory..
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 9
Reputation: j3p0yz is an unknown quantity at this point 
Solved Threads: 0
j3p0yz j3p0yz is offline Offline
Newbie Poster

Re: JAVA Illegal Start of Expression Error

 
0
  #9
Jun 12th, 2007
h..i can anyone help me please. I'm having problem with this program. It's only one error illegal starts of expression in public void check (), at line 53. What it is mean?..


import javax.swing.JOptionPane;

class waiter


{
private double tab;
public waiter(String name);
{
System.out.println("My name is "+ name +", and i'll be your waiter!");
tab = 0.0;
}
public double priceof(String s);
{
double price;
if (s.equals("Chicken"))
{price = 5.95;}
else
{//burger fries
if (s.equals("burger"))
{price = 4.95; }
else
{price = 1.95;}

}//burger or fries
return price;
}//priceof
public void order(String s)
{
if(s.equals("Chicken"))
{
tab = tab + 5.95;
}// burger fries
else
{//burger fries
if (s.equals("Burger"))
{
tab = tab + 4.95;
}
else
{
tab = tab + 1.95;
}
}//price of

public void check()
{
System.out.println("Please pay $" + tab+",null");
}

}
public class objects3
{
public static void main(String [] args)
{
waiter ourwaiter;
ourwaiter = new waiter ("Manfred");// makes a waiter object
double x;
double y;
x = ourwaiter.priceof("burger");
y = ourwaiter.priceof("chicken");
if (x<y)// buy cheaper product
{
System.out.println("I'll take the burger because it's cheaper");
ourwaiter.order("Burger");
}
else
{
System.out.println("I'll take the chicken. ");
ourwaiter.order("chicken");
}
System.out.println("And i'll have fries with that");
ourwaiter.oreder("Fries");
System.out.println("\n eat eat....\n");

ourwaiter.check();
}
}
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,433
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: JAVA Illegal Start of Expression Error

 
0
  #10
Jun 12th, 2007
As Jwenting mentioned, you need to start a new thread with your question and place your code between code tags to make it more readable. See the post at the top of the forum about code tags.

An illegal start of expression means that you have misformatted your code and it cannot be parsed correctly. This would include things like missing braces or parens, declaring a method within a method, missing semi-colon, etc.
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