Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
  1. Identify errors from the following program and correct them.

import java.swing.*;

  1. import java.awt.*;
  2. public class Cake extends Panel
  3. {
  4. public final double CREAM_CHEESE = 0.50
  5. public final double BUTTER = 0.25;
  6. public final double PEACH_JELLY = 0.75;
  7. public final double BLUEBERRY_JAM = 0.75;
  8. private JCheckBox creamCheese;
  9. private JCheckBox butter;
  10. private JCheckBox peachJelly;
  11. private JCheckBox blueberryJam;
  12. public Cake()
  13. {
  14. setLayout new GridLayout(4, 1));
  15. creamCheese = new JCheckBox("Cream cheese");
  16. butter = new JCheckBox("Butter");
  17. peachJelly = new JCheckBox("Peach jelly");
  18. blueberryJam = new JCheckBox("Blueberry jam");
  19. setBorder(BorderFactory.createTitledBorder("Cake Decorations"));
  20. add(creamCheese);
  21. add(butter);
  22. add(peachJelly);
  23. add(blueberryJam);
  24. }
  25. public double getDecorationCosts()
  26. {
  27. double decorationCosts = 0;
  28. if (creamCheese.isSelected())
  29. decorationCosts += CREAM_CHEESE;
  30. if (butter.isSelected())
  31. decorationCosts += BUTTER;
  32. if (peachJelly.isSelected())
  33. decorationCosts += PEACH_JELLY;
  34. if (blueberryJam.isSelected())
  35. decorationCosts += BLUEBERRY_JAM;
  36. return decorationCosts;
  37. }

One error is already identified for you as shown below:

Line Number: 5

Error description: Missing semicolon

Statement after correction: public final double CREAM_CHEESE = 0.50;

Identify 5 other errors and give their Line Number, Error description and Statement after correction in the following table.

Line Number

Error description

Statement after correction

Expert Solution
Check Mark
Step 1

We need to identify 5 errors and give their Line Number, Error description and Statement after correction in the following table.

Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY