Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Lv 32,325 points

Teddy Bear

Favorite Answers11%
Answers698
  • Temporary internet files?

    Could someone please explain to me how temporary internet files are created on a computer and how they can be removed ?

    Thanks

    5 AnswersOther - Internet7 years ago
  • Need definition for line of code please?

    Hi

    I need to know what this line of code means:

    for(String fn : files)

    System.out.println("found " + fn);

    Could you please tell me what the "fn" function is for and why it is being used in this line of code?

    Thank you very much

    God Bless

    4 AnswersProgramming & Design9 years ago
  • 7 Errors in java code related to inheritance. Please assist me. Thank you very much.?

    Hi Everyone

    The code is: public abstract class Ball

    {

    public String type;

    public Ball(String type)

    {

    this.type = type;

    }

    abstract public void play();

    public String getType()

    {

    return type;

    }

    public abstract class Bounceable extends Ball

    {

    public Bounceable()

    {

    super("Bounceable");

    }

    abstract public String bounce();

    }

    public abstract class Baseball extends Ball

    {

    public Baseball(String msg)

    {

    super(msg);

    }

    public String usage()

    {

    return new String("The American pasttime - Batter up!");

    }

    }

    public abstract class Bowlingball extends Ball

    {

    public Bowlingball(String msg)

    {

    super(msg);

    }

    public String usage()

    {

    return new String("Set up the pins. Do you know how to score?");

    }

    }

    public abstract class Tennisball extends Bounceable

    {

    public Tennisball()

    {

    super("Tennisball");

    }

    public void play()

    {

    System.out.println("All set for a match. I love this game");

    }

    public String bounce()

    {

    String bounce = "Boing!";

    return bounce;

    }

    }

    public abstract class Basketball extends Bounceable

    {

    public Basketball()

    {

    super("Basketball");

    }

    public void play()

    {

    System.out.println("Basketball begins with a tipoff.");

    }

    public String bounce()

    {

    String bounce = "dribble...";

    return bounce;

    }

    }

    public class PolyTest

    {

    public static void main(String[] args)

    {

    Ball[] ball = {Baseball(),Basketball(),Bowlingball(),Tennisball()};

    System.out.println("For each type of ball...\n");

    for(int i = 0; i < ball.length; ++i)

    {

    System.out.println("Ball #"+(i+1)+" is a "+ball[i].getType());

    System.out.println("Playing: ");

    ball[i].play();

    //checks to see if it an object of type Bounceable

    if( ball[i] instanceof Bounceable)

    //if so, call bounce method of Bounceable object

    System.out.println("Bouncing");

    else

    System.out.println("You can't bounce this ball");

    System.out.println("\n");

    }

    System.out.println("\nEnd of program.");

    }

    }

    }

    The Errors are: java:66: error: constructor Bounceable in class Ball.Bounceable cannot be applied to given types;

    super("Tennisball");

    ^

    required: no arguments

    found: String

    reason: actual and formal argument lists differ in length

    java:85: error: constructor Bounceable in class Ball.Bounceable cannot be applied to given types;

    super("Basketball");

    ^

    required: no arguments

    found: String

    reason: actual and formal argument lists differ in length

    java:104: error: cannot find symbol

    Ball[] ball = {Baseball(),Basketball(),Bowlingball(),Tennisball()};

    ^

    symbol: method Baseball()

    location: class Ball.PolyTest

    java:104: error: cannot find symbol

    Ball[] ball = {Baseball(),Basketball(),Bowlingball(),Tennisball()};

    ^

    symbol: method Basketball()

    location: class Ball.PolyTest

    C:\Course Technology\85985-0d\Chapter10\Ball.java:104: error: cannot find symbol

    Ball[] ball = {Baseball(),Basketball(),Bowlingball(),Tennisball()};

    ^

    symbol: method Bowlingball()

    location: class Ball.PolyTest

    .java:104: error: cannot find symbol

    Ball[] ball = {Baseball(),Basketball(),Bowlingball(),Tennisball()};

    ^

    symbol: method Tennisball()

    location: class Ball.PolyTest

    C:\Course Technology\85985-0d\Chapter10\Ball.java:102: error: Illegal static declaration in inner class Ball.PolyTest

    public static void main(String[] args)

    ^

    modifier 'static' is only allowed in constant variable declarations

    The errors only start after the 3rd part:

    1st i had to create an abstract base class, Ball. The single constructor requires a string to indicate the type of ball which is then stored in an instance variable. Instance method getType(), returns a new string containing the type of ball. The class declares an abstract method play(), which returns void. Then i have to create an abstract class Bounceable which inherits from ball which has a single abstract method bounce() which returns a string but n no instance variables. then create 2 concrete classes Baseball and Bowlingball, which inherits from ball. only implementation of inherited abstract methods. no instance variables or additional methods required. My code compiles up till this point, then the problem comes in here: Next i have to create 2 concrete classes Tennisball and Basketball which inherit from Bounceable. No instance variables or methods required only implementation

    3 AnswersProgramming & Design9 years ago
  • 3 Errors in Java code. Please help.?

    Hi I need some help with this code please: import java.io.*;

    import javax.swing.JOptionPane;

    import java.text.DecimalFormat;

    public class Tuition

    {

    public static void main(String[] args)

    {

    //Declare Variables

    int hours;

    double fees, rate, tuition;

    //Call Methods

    displayWelcome();

    hours = getHours();

    rate = getRate(hours);

    tuition = calcTuition(hours, rate);

    fees = calcFees(tuition);

    displayTotal(tuition + fees);

    }

    public static void displayWelcome()

    {

    System.out.println("Welcome to the Tuition and Fees Calculator");

    }

    public static int getHours()

    {

    //Declare Variables

    BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));

    String strHours;

    int hours = 0;

    try

    {

    //Prompt User for input

    System.out.println("\t\tEnter total number of hours used by students");

    hours = dataIn.readLine();

    hours = Integer.parseInt(strHours);

    }

    catch(NumberFormatException e)

    {

    System.out.println("Please input whole numbers");

    }

    return hours;

    }

    public static double getRate(int hours)

    {

    if (hours > 15)

    {

    System.out.println("\t\tCalculate rate per credit hour");

    }

    else

    if(hours < 15)

    {

    System.out.println("Credit hours are inaccurate");

    }

    return Rate;

    }

    public static double calcTuition(int hours, double rate)

    {

    //Accept two values

    rate = rate * hours;

    return Tuition;

    }

    public static double calcFees(double tuition)

    {

    //Accept double Value

    double fees;

    fees = tuition * 0.8;

    return fees;

    }

    public static void displayTotal(double total)

    {

    //Construct DecimalFormat pattern for currency

    DecimalFormat twoDigits = new DecimalFormat("$000.00");

    double fees;

    double tuition;

    System.out.println("Your total is: "+ tuition+".");

    }

    }

    The Errors are: java:49: error: incompatible types

    hours = dataIn.readLine();

    java:74: error: cannot find symbol

    return Rate;

    java:82: error: cannot find symbol

    return Tuition;

    In the dataIn.readLine statement, I have hours twice because I dont know what else to use. I have tried all the others like rate, tuition etc, but cant come right there. Also the two return statements; rate and tuition are incorrect. Could someone please assist me here.

    Thank You. God Bless :-)

    2 AnswersProgramming & Design9 years ago
  • Java Primitive data types question.?

    Hi there I need some help with a particular definition in java that is related to primitive data types. In many descriptions like the byte, int , long and short data types it is described in, for example, the byte stores whole number values in 8-bit signed locations from -128 to +127. I need to know what exactly are bit signed locations.

    Thank You for the help

    God Bless

    2 AnswersProgramming & Design9 years ago
  • 2 Errors in Java debugging Assignment, please help :-)?

    Hi everyone

    This program is not running due to 2 errors could someone please assist me? Thanks :-)

    Code: import java.io.BufferedReader;

    import java.io.IOException;

    import java.io.InputStreamReader;

    public class UserList

    {

    public static void main(String[] args) throws Exception

    {

    String str1, str2 = "username";

    int index;

    int initialCapacity = 10;

    BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));

    ArrayList(String) users = new ArrayList(String)();

    System.out.print("Enter a user name: ");

    str1 = dataIn.readLine();

    while(str1.length() > 0)

    {

    if(str1 == str2);

    System.out.println("That user name is NOT allowed!");

    else

    {

    if(users.size() == initialCapacity)

    {

    System.out.println("List is full!");

    System.out.println("Last entry is "+users.get(initialCapacity));

    }

    else

    if(!users.contains(str1))

    {

    users.add(str1);

    System.out.println("User \""+str1+"\" added to user list.");

    }

    else

    System.out.println("User \""+str1+"\" already in user list.");

    }

    System.out.print("\nEnter a user name: ");

    str1 = dataIn.readLine();

    }

    System.out.println("Program complete.");

    }

    }

    Errors: C:\Course Technology\85985-0d\Chapter09\v4.1\UserList.java:22: ';' expected

    ArrayList(String) users = new ArrayList(String)();

    ^

    C:\Course Technology\85985-0d\Chapter09\v4.1\UserList.java:31: 'else' without 'if'

    else

    ^

    2 errors

    Thank You :-)

    2 AnswersProgramming & Design9 years ago
  • one error in Java code Please help?

    Hi Everyone

    I need help with this code please. This code is created to import a adjustable graphic in an Applet.

    Code: import java.awt.*;

    import java.awt.event.*;

    import java.applet.*;

    public class MoveIt extends Applet implements ActionListener

    {

    // Declare Variables

    private Image cup;

    private Panel keyPad;

    public int top = 15;

    public int left = 15;

    private Button keysArray[];

    public void init()

    {

    cup = getImage(getDocumentBase(), "cup.gif");

    Canvas myCanvas = new Canvas();

    // Construct Panel and Buttons

    keypad = new Panel();

    keys[1] = new Button("Up");

    keys[2] = new Button("Left");

    keys[3] = new Button("Right");

    keys[4] = new Button("Down");

    keys[5] = new Button("Center");

    // Set Background Color

    setBackground(blue);

    // Set Layout Manager for Frame

    this.setLayout(new BorderLayout());

    // Set keypad Layout Manager

    this.setLayout(new BorderLayout());

    //Add Buttons to the keypad Panels

    keypad.add(Up, BorderLayout.NORTH);

    keypad.add(Down, BorderLayout.SOUTH);

    keypad.add(Left, BorderLayout. EAST);

    keypad.add(Right, BorderLayout.WEST);

    keypad.add(Center, BorderLayout.Center);

    add(myCanvas, BorderLayout.NORTH);

    add(keypad, BorderLayout.SOUTH);

    // Add ActionListener Statements for each of the Buttons

    UpButton.addActionListener(this);

    DownButton.addActionListener(this);

    LeftButton.addActionListener(this);

    RightButton.addActionListener(this);

    CenterButton.addActionListener(this);

    }

    public void paint(Graphics g)

    {

    g.drawImage(cup, left, top, this);

    }

    public void actionPerformed(ActionEvent e)

    {

    String arg = e.getActionCommand();

    if(arg == "Up")

    top = top -15;

    if(arg == "Down")

    top = top + 15;

    if(arg == "Left")

    top = top - 15;

    if(arg == "Right")

    top = top + 15;

    if(arg == "Center")

    top = 60;

    Left = 125;

    }

    repaint();

    }

    Error is: :\Course Technology\59850_Java3e_DF1-4\Chapters 5-8\Chapter06\MoveIt.java:90: invalid method declaration; return type required

    repaint();

    ^

    1 error

    Thank You :-)

    2 AnswersProgramming & Design9 years ago
  • How do I override this method in java? Please help?

    Hi

    I have created an Applet that calculates the shipping costs of items purchased by customers. This is the code: import java.applet.*;

    import java.awt.*;

    import java.awt.event.ItemListener;

    import java.text.DecimalFormat;

    public class CandleLine extends Applet implements ItemListener

    {

    //Declare Variables

    double dollars, answer;

    int shippingCode;

    //Construct Components for applet

    Label welcome = new Label("Welcome to CandleLine online");

    Label OrderEntryLabel = new Label("Please Enter the total amount of you order");

    TextField OrderEntryField = new TextField(7);

    Label codeLabel = new Label("Select the appropriate shipping method");

    CheckboxGroup codeGroup = new CheckboxGroup();

    Checkbox PriorityBox = new Checkbox("Priority Delivery; overnight",false,codeGroup);

    Checkbox ExpressBox = new Checkbox("Express Delivery; 2 business days",false,codeGroup);

    Checkbox StandardBox = new Checkbox("Standard Delivery; 3-7 business days",false,codeGroup);

    Checkbox hiddenBox = new Checkbox("",true,codeGroup);

    Label Guarantee = new Label("We will guarantee on-time delivery, or your money back ");

    Label outputLabel = new Label("");

    public void init()

    {

    setForeground(Color.black);

    setBackground(Color.cyan);

    add(welcome);

    add(OrderEntryField);

    add(OrderEntryLabel);

    add(PriorityBox);

    PriorityBox.addItemListener(this);

    add(ExpressBox);

    ExpressBox.addItemListener(this);

    add(StandardBox);

    StandardBox.addItemListener(this);

    add(outputLabel);

    add(Guarantee);

    }

    public void ItemStateChanged(ItemListener choice)

    {

    try

    {

    dollars = getSales();

    shippingCode = getCode();

    answer = getShipping(dollars,shippingCode);

    output(answer, dollars);

    }

    catch(NumberFormatException e)

    {

    outputLabel.setText("You must enter a dollar amount greater than zero");

    hiddenBox.setState(true);

    OrderEntryField.setText("");

    OrderEntryField.requestFocus();

    }

    }

    public double getSales()

    {

    double total = Double.parseDouble(OrderEntryField.getText());

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

    return total;

    }

    public int getCode()

    {

    int code = 0;

    if (PriorityBox.getState()) code = 1;

    else

    if (ExpressBox.getState()) code = 2;

    else

    if (StandardBox.getState()) code = 3;

    return code;

    }

    public double getShipping(double Total, int code)

    {

    double shipping = 0.0;

    switch(code)

    {

    case 1:

    shipping = 16.95;

    break;

    case 2:

    shipping = 13.95;

    break;

    case 3:

    if(Total>100) shipping = 0.0;

    else if(Total<=100) shipping = 7.95;

    break;

    }

    return shipping;

    }

    public void output(double shipping, double total)

    {

    DecimalFormat twoDigits = new DecimalFormat("$#,0000.00");

    outputLabel.setText("Your shipping on sales of " + twoDigits.format(total) + " is "+twoDigits.format(shipping));

    }

    }

    This is the Error: C:\Users\user\Desktop\Assignment 2\CandleLine.java:17: CandleLine is not abstract and does not override abstract method itemStateChanged(java.awt.event.ItemEvent) in java.awt.event.ItemListener

    public class CandleLine extends Applet implements ItemListener

    ^

    1 error

    I need to know what code to use to override this method. Could someone please assist me?

    Thank You :-)

    1 AnswerProgramming & Design9 years ago
  • 2 errors In Checkerboard java code Please Help?

    Hi Everyone

    could someone please help me correct these 2 errors. This program is to create an application that demonstrates Array and Looping structures.

    Code: import java.awt.*;

    import java.awt.event.*;

    import javax.swing.JOptionPane;

    public class Checkerboard extends Frame implements ActionListener

    {

    //Declare the Panels that holds the Array

    Panel boardPanel = new Panel();

    TextArea numberArea[] = new TextArea[16];

    ////Declares the Panel that holds three fiels and labels

    Panel buttonPanel = new Panel();

    Button goBut = new Button("Go");

    Label startLabel = new Label("Start");

    Label stepLabel = new Label("Step");

    Label stopLabel = new Label("Stop");

    Panel inputPanel = new Panel();

    int start=0, stop=0, step=0;

    TextField startField = new TextField();

    TextField stepField = new TextField();

    TextField stopField = new TextField();

    public Checkerboard()

    {

    // set layouts for frame and two panels

    this.setLayout(new BorderLayout());

    boardPanel.setLayout(new GridLayout(4,4));

    inputPanel.setLayout(new GridLayout(2,3));

    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

    // add components to board Panel

    for (int i = 0; i < numberArea.length; i++) {

    numberArea[i] = new TextArea(null, 3, 5, 3);

    numberArea[i].setText(Integer.toString(i));

    numberArea[i].setEditable(false);

    numberArea[i].setBackground(Color.WHITE);

    boardPanel.add(numberArea[i]);

    }

    // add components to input Panel

    inputPanel.add(startField);

    inputPanel.add(stepField);

    inputPanel.add(stopField);

    inputPanel.add(startLabel);

    inputPanel.add(stepLabel);

    inputPanel.add(stopLabel);

    //buttonPanel Component

    buttonPanel.add(goBut);

    // add panels to frame

    add(boardPanel, BorderLayout.NORTH);

    add(inputPanel, BorderLayout.CENTER);

    add(buttonPanel, BorderLayout.SOUTH);

    goBut.addActionListener(this);

    // overriding the windowClosing() method will allow the user to click the Close button

    addWindowListener(new WindowAdapter() {

    public void windowClosing(WindowEvent e) {

    System.exit(0);

    }

    });

    }// end of constructor method

    public static void main(String[] args)

    {

    Checkerboard f = new Checkerboard();

    f.setBounds(50, 100, 300, 400);

    f.setTitle("Checkerboard Array");

    f.setVisible(true);

    }// end of main() method

    public void actionPerformed(ActionEvent e)

    {

    String arg = e.getActionCommand();

    try

    {

    start = Integer.parseInt(startField.getText());

    step = Integer.parseInt(stepField.getText());

    stop = Integer.parseInt(stopField.getText());

    }catch(Exception exception)

    {

    return;

    }

    Object src = e.getSource();

    for (int x = start -1; x < stop; x = step) //you need to do the -1 because the array subscript values in Java all start

    //with zero, but humans use numbers starting with 1

    {

    //numberArea[x] = numberArea[start & start++].setBackground(Color.magenta);//..change the color for that square here

    if (src == goBut)

    {

    if (start >= 0 && start <= 15 && start < stop) {

    numberArea[x] = numberArea[start + start++].setBackground(Color.magenta);

    }

    else

    {

    JOptionPane

    .showMessageDialog(

    null,

    "You have entered an incorrect number or a number larger than 15. Please try again",

    "Error", JOptionPane.ERROR_MESSAGE);

    }

    if (step >= 0 && step <= 15 && start < stop) {

    numberArea[x] = numberArea[step + step++].setBackground(Color.yellow);

    }

    }

    }

    }

    }

    Errors: C:\Users\user\Desktop\Checkerboard.java:111: incompatible types

    found : void

    required: java.awt.TextArea

    numberArea[x] = numberArea[start + start++].setBackground(Color.magenta);

    ^

    C:\Users\user\Desktop\Checkerboard.java:124: incompatible types

    found : void

    required: java.awt.TextArea

    numberArea[x] = numberArea[step + step++].setBackground(Color.yellow);

    3 AnswersProgramming & Design9 years ago
  • Error in CandleLine Java code Please Help?

    Hi everyone could someone please help me in solving this one error that i have in this code. This is an Applet that calculates the shipping costs of items purchased by customers:

    import java.applet.*;

    import java.awt.*;

    import java.awt.event.ItemListener;

    import java.text.DecimalFormat;

    public class CandleLine extends Applet implements ItemListener

    {

    //Declare Variables

    double dollars, answer;

    int shippingCode;

    //Construct Components for applet

    Label welcome = new Label("Welcome to CandleLine online");

    Label OrderEntryLabel = new Label("Please Enter the total amount of you order");

    TextField OrderEntryField = new TextField(7);

    Label codeLabel = new Label("Select the appropriate shipping method");

    CheckboxGroup codeGroup = new CheckboxGroup();

    Checkbox PriorityBox = new Checkbox("Priority Delivery; overnight",false,codeGroup);

    Checkbox ExpressBox = new Checkbox("Express Delivery; 2 business days",false,codeGroup);

    Checkbox StandardBox = new Checkbox("Standard Delivery; 3-7 business days",false,codeGroup);

    Checkbox hiddenBox = new Checkbox("",true,codeGroup);

    Label Guarantee = new Label("We will guarantee on-time delivery, or your money back ");

    Label outputLabel = new Label("");

    public void init()

    {

    setForeground(Color.black);

    setBackground(Color.cyan);

    add(welcome);

    add(OrderEntryField);

    add(OrderEntryLabel);

    add(PriorityBox);

    PriorityBox.addItemListener(this);

    add(ExpressBox);

    ExpressBox.addItemListener(this);

    add(StandardBox);

    StandardBox.addItemListener(this);

    add(outputLabel);

    add(Guarantee);

    }

    public void ItemStateChanged(ItemListener choice)

    {

    try

    {

    dollars = getSales();

    shippingCode = getCode();

    answer = getShipping(dollars,shippingCode);

    output(answer, dollars);

    }

    catch(NumberFormatException e)

    {

    outputLabel.setText("You must enter a dollar amount greater than zero");

    hiddenBox.setState(true);

    OrderEntryField.setText("");

    OrderEntryField.requestFocus();

    }

    }

    public double getSales()

    {

    double total = Double.parseDouble(OrderEntryField.getText());

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

    return total;

    }

    public int getCode()

    {

    int code = 0;

    if (PriorityBox.getState()) code = 1;

    else

    if (ExpressBox.getState()) code = 2;

    else

    if (StandardBox.getState()) code = 3;

    return code;

    }

    public double getShipping(double Total, int code)

    {

    double shipping = 0.0;

    switch(code)

    {

    case 1:

    shipping = 16.95;

    break;

    case 2:

    shipping = 13.95;

    break;

    case 3:

    if(Total>100) shipping = 0.0;

    else if(Total<=100) shipping = 7.95;

    break;

    }

    return shipping;

    }

    public void output(double shipping, double total)

    {

    DecimalFormat twoDigits = new DecimalFormat("$#,0000.00");

    outputLabel.setText("Your shipping on sales of " + twoDigits.format(total) + " is "+twoDigits.format(shipping));

    }

    }

    Error: C:\Course Technology\59850d\Chapter 04\CandleLine.java:17: CandleLine is not abstract and does not override abstract method itemStateChanged(java.awt.event.ItemEvent) in java.awt.event.ItemListener

    public class CandleLine extends Applet implements ItemListener

    ^

    1 error

    Thank You :-)

  • Two Errors in Java code Please help?

    Hi could someone please assist me in correcting these two errors?

    code: import java.awt.*;

    import java.applet.*;

    import java.awt.event.*;

    import java.awt.Label.*;

    public class Freddie extends Applet implements ItemListener

    {

    //Construct Components

    Label sandwichPromptLabel = new Label("sandwich");

    Label sandwichInputField = new TextField("Input");

    Label sizePromptLabel = new Label("size");

    CheckboxGroup sandwichGroup = new CheckboxGroup();

    Checkbox catsupBox = new Checkbox("catsup",false,sandwichGroup);

    Checkbox mustardBox = new Checkbox("mustard",false,sandwichGroup);

    Checkbox picklesBox = new Checkbox("pickles",false,sandwichGroup);

    Checkbox sizeGroupBox = new Checkbox("sizeGroup",true,sandwichGroup);

    Checkbox smallBox = new Checkbox("small",false,sandwichGroup);

    Checkbox mediumBox = new Checkbox("medium",false,sandwichGroup);

    Checkbox largeBox = new Checkbox("large",false,sandwichGroup);

    public void init()

    {

    setBackground(red);

    add(sizePromptLabel);

    add(sandwichInputField);

    add(sizePromptLabel);

    add(catsupBox);

    catsupBox.addItemListener(this);

    add(mustardBox);

    mustardBox.addItemListener(this);

    add(picklesBox);

    picklesBox.addItemListener(this);

    add(sizeGroupBox);

    sizeGroupBox.addItemListener(this);

    add(smallBox);

    smallBox.addItemListener(this);

    add(mediumBox);

    mediumBox.addItemListener(this);

    add(largeBox);

    largeBox.addItemListener(this);

    }

    public void itemStateChanged(ItemEvent choice)

    {

    }

    }

    Errors: C:\Course Technology\59850d\Chapter 04\Freddie.java:22: incompatible types

    found : java.awt.TextField

    required: java.awt.Label

    Label sandwichInputField = new TextField("Input");

    ^

    C:\Course Technology\59850d\Chapter 04\Freddie.java:36: cannot find symbol

    symbol : variable red

    location: class Freddie

    setBackground(red);

    ^

    2 errors

    Thank You :-)

    3 AnswersProgramming & Design9 years ago
  • one error in Java code Please help?

    Hi could someone please help me with this code I have one error. The program creates an applet related to Fast-Food Sandwiches created at Freddie's fast food:

    import java.awt.*;

    import java.applet.*;

    import java.awt.event.*;

    public class Freddie extends Applet implements ItemListener

    {

    public void init()

    {

    //Construct Components

    Label sandwichPromptLabel = new Label("sandwich");

    Label sandwichInputField = new TextField("Input");

    Label sizePromptLabel = new Label("Size");

    CheckboxGroup sandwichGroup = new CheckboxGroup();

    Checkbox catsupBox = new Checkbox("catsup",false,sandwichGroup);

    Checkbox mustardBox = new Checkbox("mustard",false,sandwichGroup);

    Checkbox picklesBox = new Checkbox("pickles",false,sandwichGroup);

    Checkbox sizeGroupBox = new Checkbox("sizeGroup",true,sandwichGroup);

    Checkbox smallBox = new Checkbox("small",false,sandwichGroup);

    Checkbox mediumBox = new Checkbox("medium",false,sandwichGroup);

    Checkbox largeBox = new Checkbox("large",false,sandwichGroup);

    public void init()

    {

    setBackground(red);

    add(promptLabel);

    add(inputField);

    add(size);

    add(catsup);

    add(mustard);

    add(pickles);

    add(sizeGroup);

    add(small);

    add(medium);

    add(large);

    public void itemStateChanged(ItemEvent choice)

    {

    }

    };};};

    This is the Error:

    C:\Course Technology\59850d\Chapter 04\Freddie.java:35: illegal start of expression

    public void init()

    ^

    1 error

    Thank You :-)

    2 AnswersProgramming & Design9 years ago
  • Need help with one error in java code?

    Hi everyone

    I am writing a program that calculates the total cost of students' fees and I seem to have one error that I cannot correct. This error is on line 61import java.io.*;

    import javax.swing.JOptionPane;

    import java.text.DecimalFormat;

    public class Tuition

    {

    public static void main(String[] args);

    {

    //Declare Variables

    int hours;

    double fees, rate, tuition;

    //Call Methods

    displayWelcome();

    hours = getHours();

    rate = getRate(hours);

    tuition = calcTuition(hours, rate);

    fees = calcFees(tuition);

    displayTotal(tuition + fees);

    }

    public static void displayWelcome()

    {

    System.out.println("Welcome to the Tuition and Fees Calculator");

    }

    public static int getHours()

    {

    //Declare Variables

    String = strHours;

    int hours = 0;

    //Prompt user for Input

    System.out.println("Enter total number of hours used by students");

    try

    {

    hours = Integer.parseInt(strHours);

    }

    catch(NumberFormatException e)

    {

    JOptionPane.showMessageDialog(null,"Your entry was invalid.","Error",JOptionPane.INFORMATION_MESSAGE);

    {

    System.out.println("Please input whole numbers");

    }

    return hours;

    }

    public static double getRate(int hours)

    {

    int hours = 15;

    if (hours > 15){

    System.out.println("Calculate rate per credit hour");

    return rate;

    }

    else

    if(hours<15){

    System.out.println("Credit hours are inaccurate");

    }

    public static double calcTuition(int hours, double rate)

    {

    //Accept two values

    int hours

    int rate = 0.0;

    int rate * hours;

    return tuition;

    }

    public static double calcFees(double tuition)

    {

    //Accept double Value

    double tuition * 0.8;

    double fees

    return fees;

    }

    public static void displayTotal(double total)

    {

    //Construct DecimalFormat pattern for currency

    DecimalFormat Currency = new DecimalFormat("$000.00");

    System.out.println("Your total tuition is " fees + tuition);

    }

    };

    };}; :

    Error: C:\Course Technology\59850d\Chapter 04\Tuition.java:61: illegal start of expression

    public static double getRate(int hours)

    ^

    1 error

    Thank You :)

    1 AnswerProgramming & Design9 years ago
  • one error in Java code Please help?

    Hi everyone

    I am writing this code that uses an input box that has three choices and I am having trouble parsing the value afterward :

    import java.io.*;

    import javax.swing.JOptionPane;

    public class MyType

    {

    public static void main (String[] args)

    {

    // Declare and Construct Variables

    String strChoice, strTryString, strTryInt, strTryDouble;

    int choice, tryInt;

    double tryDouble;

    boolean done = false;

    //loop while user does not click cancel button

    while(!done)

    {

    try

    {

    String message = "What is My Type?" +

    "\n\n1) String\n2) Integer\n3) double\n4) Quit the program\n\n";

    choice = Integer.parseInt(strChoice);

    switch(choice)

    {

    case 1:

    JOptionPane.showMessageDialog(null, "Correct, any input can be saved as a String");

    break;

    case 2:

    JOptionPane.showMessageDialog(null, "Correct");

    tryInt = Integer.parseInt(strChoice);

    break;

    case 3:

    JOptionPane.showMessageDialog(null, "Correct");

    tryDouble = Integer.parseInt(strChoice);

    break;

    case 4:

    JOptionPane.showMessageDialog(null, "Exit.");

    done = true;

    break;

    default:

    throw new NumberFormatException();

    }

    }

    catch(NumberFormatException e)

    {

    JOptionPane.showMessageDialog(null,"Please try again");

    }

    }

    }

    }

    Thank You :-)

    1 AnswerProgramming & Design9 years ago
  • what are good movies to download?

    Hey there could someone please tell me what would be a good vampire movie to download, except twilight and from what websites please? Also any other good comedies

    Thanks :-)

    2 AnswersMovies10 years ago
  • Need help with Java methods please?

    Hi

    I am having some trouble understanding the following methods in Java, their definitions and how they are used in programs. Could someone Please assist me? Thank You.

    They are:

    getDefaultToolkit()

    getSystemClipboard()

    getContents()

    setContents()

    getTransferData()

    getDesktopProperty()

    getImage()

    Please assist me

    Thank You

    2 AnswersProgramming & Design10 years ago
  • Could someone please suggest some gaming websites?

    hey there, could someone please help me out with some gaming websites?

    Thanks

    1 AnswerPC10 years ago
  • Whats a really good movie to download?

    Hi could someone please tell me what is a good horror or comedy to download?

    I really don't know what to get. Preferably something hilarious.

    3 AnswersMovies1 decade ago
  • Please assist in Java question?

    Hi

    The question states: "List three sets of test data for a program that determines the quotient A/B, where A must be an integer between -1 and 10, and B must be a non zero."

    Thank You

    1 AnswerProgramming & Design1 decade ago
  • Generalization hierarchy in java?

    Could someone please help me draw a generalization hierarchy for a book object in java, including a superclass and two subclasses?

    Thank You

    1 AnswerProgramming & Design1 decade ago