Results 1 to 2 of 2

Thread: Help with error

  1. #1
    Anime101 is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default Help with error

    I'm trying to do a tutorial out of book, but I keep geting errors, the errors I got are listed at the bottom of the page. Here's the code:
    Thanks for any help given.

    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;

    public class CommissionApplet extends Applet implements ItemListener
    {
    //declare variables and construct a color
    double dollars, answer;
    int empCode;
    Image dollarSign;
    Color darkRed = new Color(160, 50, 0);

    //Create components for applet
    Label promptLabel = new Label ("Enter sales amount(do not use commas or dollar signs):");
    TextField salesField = new TextField (20);

    Label codeLabel = new Label ("Select the appropriate commission code:");

    CheckboxGroup codeGroup = new CheckboxGroup();
    CheckBox telephoneBox = new Checkbox("Telephone Sales",false,codeGroup);
    CheckBox inStoreBox = new Checkbox ("In-Store Sales",false,codeGroup);
    CheckBox outsideBox = new Checkbox("Outside Sales",false,codeGroup);
    CheckBox hiddenBox = new Checkbox ("",true,codeGroup);

    Label outputLabel = new Label ("Click an option button to calculate the sales commission.");

    public void init()
    {
    setBackground (darkRed);
    setForeground (Color.white);
    add(promptLabel);
    add(salesField);
    salesField.requestFocus();
    salesField.setForeground(Color.black);
    add(codeLabel);
    add(telephoneBox);
    telephoneBox.addItemListener(this);
    add(inStoreBox);
    inStoreBox.addItemListener(this);
    add(outsideBox);
    outsideBox.addItemListener(this);
    add(outputLabel);
    }

    //This method is triggered by the user clicking an option button
    public void itemStateChanged(ItemEvent choice)
    {
    try
    {
    dollars = getSales();
    empCode = getCode();
    answer = getComm(dollars,empCode);
    output(answer,dollars);
    }

    catch(NumberFormatException e)
    {
    outputLabel.setText("You must enter a dollar amount greater than zero.");
    hiddenBox.setState(true);
    salesField.setText("");
    salesField.requestFocus();
    }
    }

    public double getSales()
    {
    double sales = Double.parseDouble(salesField.getText());

    if (sales <= 0) throw new NumberFormatException();

    return sales;
    }

    public int getCode()
    {
    int code = 0;
    if (telephoneBox.getState()) code = 1;
    else
    if (inStoreBox.getState()) code = 2;
    else
    if (outsideBox.getState()) code= 3;
    return code;
    }

    public double getComm(double sales, int code)
    {
    double commission = 0.0;
    switch (code)
    {
    case 1:
    commission = .10 * sales;
    break;

    case 2:
    commission = .14 * sales;
    break;

    case 3:
    commission = .18 * sales;
    break;
    }
    return commission;
    }

    public void output (double commission, double sales)
    {
    DecimalFormat twoDigits = new DecimalFormat("$#,000.00");
    outputLabel.setText("Your commission on sales of " + twoDigits.format(sales) +
    " is " + twoDigits.format(commission));
    }
    public void paint (Graphics g)
    {
    dollarSign = getImage(getDocumentBase(), "dollarSign.gif");
    g.drawImage(dollarSign,12,28,this);
    }
    }


    And here's the error's I get when I compile


    G:\CommissionApplet.java:30: cannot find symbol
    symbol : class CheckBox
    location: class CommissionApplet
    CheckBox telephoneBox = new Checkbox("Telephone Sales",false,codeGroup);
    ^
    G:\CommissionApplet.java:31: cannot find symbol
    symbol : class CheckBox
    location: class CommissionApplet
    CheckBox inStoreBox = new Checkbox ("In-Store Sales",false,codeGroup);
    ^
    G:\CommissionApplet.java:32: cannot find symbol
    symbol : class CheckBox
    location: class CommissionApplet
    CheckBox outsideBox = new Checkbox("Outside Sales",false,codeGroup);
    ^
    G:\CommissionApplet.java:33: cannot find symbol
    symbol : class CheckBox
    location: class CommissionApplet
    CheckBox hiddenBox = new Checkbox ("",true,codeGroup);
    ^
    4 errors

    Tool completed with exit code 1

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. error 530 error authentication required
    By rgale in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-12-2008, 05:28 PM

Posting Permissions

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