code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Freddie extends Applet implements ItemListener
{
int sandwiches = 0;
String fCode="", dCode="", cCode="";
Label sandwichPromptLabel = new Label("Number of sandwiches ordered:");
TextField sandwichInputField = new TextField(5);
Label friesLabel = new Label("Fries serving size: ");
CheckboxGroup friesGroup = new CheckboxGroup();
Checkbox smallFries = new Checkbox("Small",false,friesGroup);
Checkbox mediumFries = new Checkbox("Medium",false,friesGroup);
Checkbox largeFries = new Checkbox("Large",false,friesGroup);
Label drinkLabel = new Label("Drink serving size: ");
CheckboxGroup drinkGroup = new CheckboxGroup();
Checkbox smallDrink = new Checkbox("Small",false,drinkGroup);
Checkbox mediumDrink = new Checkbox("Medium",false,drinkGroup);
Checkbox largeDrink = new Checkbox("Large",false,drinkGroup);
Label condimentsLabel = new Label(" Condiments: ");
Checkbox catsupBox = new Checkbox("Catsup");
Checkbox mustardBox = new Checkbox("Mustard");
Checkbox picklesBox = new Checkbox("Pickles");
Label outputLabelSandwiches = new Label("");
Label outputLabelDrink = new Label("");
Label outputLabelFries = new Label("");
Label outputLabelCondiments = new Label("");
Label warningLabel = new Label("");
public void init()
{
setBackground(Color.red);
add(sandwichPromptLabel);
add(sandwichInputField);
sandwichInputField.requestFocus();
add(friesLabel);
add(smallFries);
smallFries.addItemListener(this);
add(mediumFries);
mediumFries.addItemListener(this);
add(largeFries);
largeFries.addItemListener(this);
add(drinkLabel);
add(smallDrink);
smallDrink.addItemListener(this);
add(mediumDrink);
mediumDrink.addItemListener(this);
add(largeDrink);
largeDrink.addItemListener(this);
add(condimentsLabel);
add(catsupBox);
catsupBox.addItemListener(this);
add(mustardBox);
mustardBox.addItemListener(this);
add(picklesBox);
picklesBox.addItemListener(this);
add(outputLabelSandwiches);
add(outputLabelFries);
add(outputLabelDrink);
add(outputLabelCondiments);
add(warningLabel);
}
//This method is triggered by the user clicking an option button
public void itemStateChanged(ItemEvent choice)
{
try
{
sandwiches = getSandwiches(0);
fCode = getFries("");
dCode = getDrink("");
cCode = getCondiments("");
sendOutput(sandwiches,fCode,dCode,cCode); <<<<< cannot resolve symbol
}
catch (NumberFormatException e)
{
warningLabel.setText("You must enter an integer value.");
sandwichPromptLabel.setText("");
sandwichPromptLabel.requestFocus();
}
}
public int getSandwiches(int sandwiches)
{
sandwiches = Integer.parseInt(sandwichInputField.getText());
return sandwiches;
}
public String getFries(String fCode)
{
fCode = "";
if (smallFries.getState()) fCode = "Small";
else
if (mediumFries.getState()) fCode = "Medium";
else
if (largeFries.getState()) fCode = "Large";
return fCode;
}
public String getDrink(String dCode)
{
dCode = "";
if (smallDrink.getState()) dCode = "Small";
else
if (mediumDrink.getState()) dCode = "Medium";
else
if (largeDrink.getState()) dCode = "Large";
return dCode;
}
public String getCondiments(String cCode)
{
cCode = "";
if (catsupBox.getState()) cCode = "1";
else
if (mustardBox.getState()) cCode = "2";
else
if (picklesBox.getState()) cCode = "3";
return cCode;
}
public void int String sendOutput(int sandwiches, String fCode, String dCode, String cCode)
{
outputLabelSandwiches.setText("# of sandwiches ordered: " + sandwiches);
outputLabelFries.setText("Size of fries ordered: " + fCode);
outputLabelDrink.setText("Size of drink ordered: " + dCode);
outputLabelCondiments.setText("Condiments ordered: " + cCode);
}
} <<<<< '(' expected