1 Replies - 281 Views - Last Post: 09 October 2012 - 04:06 AM Rate Topic: -----

#1 Sette  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-October 12

100 errors of class, interface , or enum expected

Posted 09 October 2012 - 02:42 AM

import java.awt.*;
import java. awt.event.*;
import java.applet.Applet;

public class system extends Applet implements ItemListener, ActionListener{
int a, b, c, d;

Label welcomeLbl = new Label("<3WELCOME TO FINEST RESTAURANT<3");

CheckBox diBox = new CheckBox("Dine-In");
TextField emTxt = new TextField(10);
CheckBox toBox = new CheckBox("Take-Out");

Label foodsLbl = new Label("Foods Available");
Label drinksLbl = new Label("Drinks Available");

Label quantity1Lbl = new Label("Quantity");
Label price1Lbl = new Label("Price");

Label quantity2Lbl = new Label("Quantity");
Label price2Lbl = new Label("Price");

Button sButton = new Button("SINIGANG");
TextField sQtyTxt = new TextField(5);
TextField sPTxt = new TextField(5);

Button hcButton = new Button("HOT COFFEE");
TextField hcQtyTxt = new TextField(5);
TextField hcPTxt = new TextField(5);

Button bButton = new Button("BULALO");
TextField bQtyTxt = new TextField(5);
TextField bPTxt = new TextField(5);

CheckboxGroup optGroup = new CheckboxGroup();
Checkbox reg1 = new Checkbox("Regular",false,optGroup);
Checkbox lar1 = new Checkbox("Large",false,optGroup);

Button nButton = new Button("NILAGA");
TextField nQtyTxt = new TextField(5);
TextField nPTxt = new TextField(5);

Button hchButton = new Button("HOT CHOCO");
TextField hchQtyTxt = new TextField(5);
TextField hchPTxt = new TextField(5);

Button kkButton = new Button("KARE-KARE");
TextField kkQtyTxt = new TextField(5);
TextField kkPTxt = new TextField(5);

CheckboxGroup optGroup = new CheckboxGroup();
Checkbox reg2 = new Checkbox("Regular",false,optGroup);
Checkbox lar2 = new Checkbox("Large",false,optGroup);

Button mButton = new Button("MENUDO");
TextField mQtyTxt = new TextField(5);
TextField mPTxt = new TextField(5);

Button sdaButton = new Button("SODA");
TextField sdaQtyTxt = new TextField(5);
TextField sdaPTxt = new TextField(5);

Label total1Lbl = new Label("TOTAL:");
TextField total1Txt = new TextField(10);

CheckboxGroup optGroup = new CheckboxGroup();
Checkbox reg3 = new Checkbox("Regular",false,optGroup);
Checkbox lar3 = new Checkbox("Large",false,optGroup);

Button jButton = new Button("JUICE");
TextField jQtyTxt = new TextField(5);
TextField jPTxt = new TextField(5);

CheckboxGroup optGroup = new CheckboxGroup();
Checkbox reg4 = new Checkbox("Regular",false,optGroup);
Checkbox lar4 = new Checkbox("Large",false,optGroup);


Label total2Lbl = new Label("TOTAL:");
TextField total2Txt = new TextField(10);


Label ao1Lbl = new Label("ADD-ONS");

Label quantity3Lbl = new Label("QUANTITY");
Label price3Lbl = new Label("Price");


Button friButton = new Button("FRIES");
TextField friQtyTxt = new TextField(5);
TextField friPTxt = new TextField(5);

Label tiLbl = new Label("TOTAL ITEMS:");
TextField tiTxt = new TextField(10);

Button sunButton = new Button("SUNDAE");
TextField sunQtyTxt = new TextField(5);
TextField sunPTxt = new TextField(5);

Label taLbl = new Label("TOTAL AMOUNT:");
TextField taTxt = new TextField(10);

Button burButton = new Button("BURGER");
TextField burQtyTxt = new TextField(5);
TextField burPTxt = new TextField(5);

Label arLbl = new Label("AMOUNT RECIEVED:");
TextField arTxt = new TextField(10);

Button pieButton = new Button("PIE");
TextField pieQtyTxt = new TextField(5);
TextField piePTxt = new TextField(5);

Label tcLbl = new Label("TOTAL CHANGE:");
TextField tcTxt = new TextField(10);

Button riceButton = new Button("RICE");
TextField riceQtyTxt = new TextField(5);
TextField ricePTxt = new TextField(5);

Label total3Lbl = new Label("TOTAL:");
TextField total3Txt = new TextField(10);

Button cmpButton = new Button("COMPUTE");

Button payButton = new Button("PAY");

Button resetButton = new Button("RESET");
}

int ti, ta, total1, total2, total3, sQty, bQty, nQty, kQty, mQty, sP=0, bP=0, nP=0, kP=0, mP=0, s=0, b=0, n=0, kk=0, m=0, hcQty, hchQty, sdaQty, jQty, hcP=0, hchP=0, sdaP=0,jP=0 , hc=0, hch=0, sda=0, j=0, friQty, sunQty, burQty, pieQty, riceQty, friP=0, sunP=0, burP=0, pieP=0, riceP=0, fri=0, sun=0, bur=0, pie=0, rice=0; 
double ar=0, tc=0;

public void init(){

setLayout(new flowLayout());

add(welcomeLbl);

add(diBox);
add(emTxt );
add(toBox);

add(foodsLbl);
add(drinksLbl);

add(quantity1Lbl);
add(price1Lbl);

add(quantity2Lbl);
add(price2Lbl);

add(sButton);
sButton.addActionListener(this);
add(sQtyTxt);
add(sPTxt);

add(hcButton);
hcButton.addActionListener(this);
add(hcQtyTxt);
add(hcPTxt);

add(bButton);
bButton.addActionListener(this);
add(bQtyTxt);
add(bPTxt);

add(reg1);
reg1.addItemListener(this);
add(lar1);
lar1.addItemListener(this);

add(nButton);
nButton.addActionListener(this);
add(nQtyTxt);
add(nPTxt);

add(hchButton);
hchButton.addActionListener(this);
add(hchQtyTxt);
add(hchPTxt);

add(kkButton);
kkButton.addActionListener(this);
add(kkQtyTxt);
add(kkPTxt);

add(reg2);
reg2.addItemListener(this);
add(lar2);
lar2.addItemListener(this);

add(mButton);
mButton.addActionListener(this);
add(mQtyTxt);
add(mPTxt);

add(sdaButton);
sdaButton.addActionListener(this);
add(sdaQtyTxt);
add(sdaPTxt);

add(total1);
add(total1Txt);

add(reg3);
reg3.addItemListener(this);
add(lar3);
lar3.addItemListener(this);

add(jButton);
jButton.addActionListener(this);
add(jQtyTxt);
add(jPTxt);

add(reg4);
reg4.addItemListener(this);
add(lar4);
lar4.addItemListener(this);

add(total2Lbl);
add(total2Txt);

add(aoLbl);

add(quantity3Lbl);
add(price3Lbl);

add(friButton);
friButton.addActionListener(this);
add(friQtyTxt);
add(friPTxt);

add(tiLbl);
add(tiTxt);

add(sunButton);
sunButton.addActionListener(this);
add(sunQtyTxt);
add(sunPTxt);

add(taLbl);
add(taTxt);

add(burButton);
burButton.addActionListener(this);
add(burQtyTxt);
add(burPTxt);

add(arLbl);
add(arTxt);

add(pieButton);
burButton.addActionListener(this);
add(pieQtyTxt);
add(piePTxt);

add(tcLbl);
add(tcTxt);


add(riceButton);
riceButton.addActionListener(this);
add(riceQtyTxt);
add(ricePTxt);

add(cmpButton);
cmpButton.addActionListener(this);

add(payButton);
payButton.addActionListener(this);

add(resetButton);
resetButton.addActionListener(this);
}

public void itemStateChanged(ItemEvent e)

{
if(e.getItemSelectavle()==diBox){
emTxt.setText("ENJOY YOUR MEAL!");
}

if(e.getItemSelectable()==toBox){
emTxt.setText("ENJOY YOUR MEAL!");
}

if(reg1.getState())
a=1;
hcP=hcQty*hc+10;
hcPTxt.setText(  +hcP);

else if(lar1.getState());
a=2;
hcP=hcQty*hc+20;
hcPTxt.setText(  +hcP);

else if(reg2.getState());





public void actionPerformed(ActionEvent e)

{
String arg;


arg=e.getActionCommand();



if(e.getSource()==sButton)
{
sQty=Integer.parseInt(sQtyTxt.getText());
s=50;
sP=sQty*s;
sPTxt.setText(  +sP);
}
else 
{
sQty=Integer.parseInt(sQtyTxt.getText());
s=0;
sP=sQty*s;
sPTxt.setText(  +sP);
}


if(e.getSource()==bButton)
{
bQty=Integer.parseInt(bQtyTxt.getText());
b=60;
bP=bQty*b;
bPTxt.setText(  +bP);
}
else 
{
bQty=Integer.parseInt(bQtyTxt.getText());
b=0;
bP=bQty*b;
bPTxt.setText(  +bP);
}

if(e.getSource()==nButton)
{
nQty=Integer.parseInt(nQtyTxt.getText());
n=50;
nP=nQty*n;
nPTxt.setText(  +nP);
}
else 
{
nQty=Integer.parseInt(nQtyTxt.getText());
n=0;
nP=Qty*n;
nPTxt.setText(  +nP);
}

if(e.getSource()==sButton)
{
kkQty=Integer.parseInt(kkQtyTxt.getText());
kk=50;
kkP=sQty*s;
kkPTxt.setText(  +kkP);
}
else 
{
kkQty=Integer.parseInt(kkQtyTxt.getText());
kk=0;
kkP=kkQty*s;
kkPTxt.setText(  +kkP);
}


if(e.getSource()==sButton)
{
mQty=Integer.parseInt(mQtyTxt.getText());
m=50;
mP=mQty*m;
mPTxt.setText(  +mP);
}
else 
{
mQty=Integer.parseInt(mQtyTxt.getText());
m=0;
mP=mQty*m;
mPTxt.setText(  +mP);
}


if(e.getSource()==hcButton)
{
hcQty=Integer.parseInt(hcQtyTxt.getText());
hc=25;
hcP=hcQty*hc;
hcPTxt.setText(  +hcP);
}

else 
{
hcQty=Integer.parseInt(hcQtyTxt.getText());
hc=0;
hcP=hcQty*hc;
hcPTxt.setText(  +hcP);
}


if(e.getSource()==hchButton)
{
hchQty=Integer.parseInt(hchQtyTxt.getText());
hch=25;
hchP=hchQty*hch;
hchPTxt.setText(  +hchP);
}

else 
{
hchQty=Integer.parseInt(hchQtyTxt.getText());
hch=0;
hchP=hchQty*hc;
hchPTxt.setText(  +hchP);
}

if(e.getSource()==sdaButton)
{
sdaQty=Integer.parseInt(sdaQtyTxt.getText());
sda=25;
sdaP=hcQty*hc;
sdaPTxt.setText(  +sdaP);
}

else 
{
sdaQty=Integer.parseInt(sdaQtyTxt.getText());
sda=0;
sda=sdaQty*sda;
sdaPTxt.setText(  +sdaP);
}

if(e.getSource()==jButton)
{
jQty=Integer.parseInt(jQtyTxt.getText());
j=25;
jP=jQty*j;
jPTxt.setText(  +jP);
}

else 
{
jQty=Integer.parseInt(jQtyTxt.getText());
j=0;
jP=jQty*j;
jPTxt.setText(  +jP);
}

if(e.getSource()==friButton)
{
friQty=Integer.parseInt(friQtyTxt.getText());
fri=25;
friP=friQty*fri;
friPTxt.setText(  +friP);
}

else 
{
friQty=Integer.parseInt(friQtyTxt.getText());
fri=0;
friP=friQty*fri;
friPTxt.setText(  +friP);
}

if(e.getSource()==sunButton)
{
sunQty=Integer.parseInt(sunQtyTxt.getText());
sun=25;
sunP=sunQty*sun;
sunPTxt.setText(  +sunP);
}

else 
{
sunQty=Integer.parseInt(sunQtyTxt.getText());
sun=0;
sunP=sunQty*sun;
sunPTxt.setText(  +sunP);
}

if(e.getSource()==burButton)
{
burQty=Integer.parseInt(burQtyTxt.getText());
bur=25;
burP=burQty*bur;
burPTxt.setText(  +burP);
}

else 
{
burQty=Integer.parseInt(burQtyTxt.getText());
bur=0;
burP=burQty*bur;
burPTxt.setText(  +burP);
}

if(e.getSource()==pieButton)
{
pieQty=Integer.parseInt(pieQtyTxt.getText());
pie=25;
pieP=pieQty*bur;
piePTxt.setText(  +pieP);
}

else 
{
pieQty=Integer.parseInt(pieQtyTxt.getText());
pie=0;
pieP=pieQty*bur;
piePTxt.setText(  +pieP);
}

if(e.getSource()==riceButton)
{
riceQty=Integer.parseInt(riceQtyTxt.getText());
rice=25;
riceP=riceQty*bur;
ricePTxt.setText(  +riceP);
}

else 
{
riceQty=Integer.parseInt(riceQtyTxt.getText());
rice=0;
riceP=riceQty*bur;
ricePTxt.setText(  +riceP);
}



if(e.getSource()==compButton)
{
total1=(sP) + (bP) + (nP) + (kkP) + (mP);
total1Txt.setText(" " +total1);

total2=(hcP) + (hchP) + (sdaP) + (jP);
total2Txt.setText(" " +total2);

total3=(friP) + (sunP) + (burP) + (pieP) + (riceP);
total3Txt.setText(" " +total3);

ti=(sQty) + (bQty) + (nQty) + (kkQty) + (mQty) + (hcQty) + (hchQty) + (sdaQty) + (jQty);
tiTxt.setText(" " +ti);

ta=(sP) + (bP) + (nP) + (kkP) + (mP) + (hcP) + (hchP) + (sdaP) + (jP) + (friP) + (sunP) + (burP) + (pieP) + (riceP);
taTxt.setText(" " +ta);
}
repaint();
}

else if(e.getSource()==resetButton)	
{

diBox.setState(false);
emTxt.setText("");
toBox.setState(false);
sQtyTxt.setText(""); 
sPTxt.setText(""); 
bQtyTxt.setText("");
bPTxt.setText(""); 
reg1.setState(false);
lar1.setState(false);
nQtyTxt.setText(""); 
nPTxt.setText(""); 
kkQtyTxt.setText("");
kkPTxt.setText("");
reg2.setState(false);
lar2.setState(false);
mQtyTxt.setText(""); 
mPTxt.setText(""); 
hcQtyTxt.setText(""); 
hcPTxt.setText(""); 
hchQtyTxt.setText(""); 
hchPTxt.setText(""); 
sdaQtyTxt.setText(""); 
sdaPTxt.setText("");
total1Txt.setText("");
reg3.setState(false);
lar3.setState(false);
jQtyTxt.setText("");
jPTxt.setText(""); 
reg4.setState(false);
lar4.setState(false);
total2Txt.setText("");
friQtyTxt.setText(""); 
friPTxt.setText(""); 
sunQtyTxt.setText("");
sunPTxt.setText("");
burQtyTxt.setText(""); 
burPTxt.setText(""); 
pieQtyTxt.setText(""); 
piePTxt.setText(""); 
riceQtyTxt.setText(""); 
ricePTxt.setText(""); 
total3Txt.setText(""); 
tiTxt.setText("");
taTxt.setText("");
arTxt.setText("");
tcTxt.setText("");
a=1;
ti=0;
ta=0;
ar=0;
tc=0;
sQty=0;
bQty=0;
nQty=0;
kkQty=0;
mQty=0;
hcQty=0;
hchQty=0;
sdaQty=0;
jQty=0;
friQty=0;
sunQty=0;
burQty=0;
pieQty=0;
riceQty=0;
repaint();
}
else if(e.getSource()==payButton)
{
ar=Integer.parseInt(arTxt.getText());
change=ar-ta;
changeTxt.setText("" +change);
}
repaint();
}
} 



Is This A Good Question/Topic? 0
  • +

Replies To: 100 errors of class, interface , or enum expected

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2197
  • View blog
  • Posts: 5,224
  • Joined: 10-September 10

Re: 100 errors of class, interface , or enum expected

Posted 09 October 2012 - 04:06 AM

Your class ends at line 129 with the close brace. I didn't scroll too far beyond that point, but the mere existence of any code outside the class is confusing the compiler.

Also, it's quite common lately (I'm not sure why) to see instance variables initialized outside a constructor. For reasons of scope and visiblity, it may desirable and necessary to declare instance variables, but I suggest their initialization should be left to a constructor.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1