EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 10, Problem 7PE
Program Plan Intro

Shipping cost

Program plan:

Filename: “InsuredPackage.java”

  • Define of “InsuredPackage” class
    • Define constructor
      • Call the “super” method
      • Declare the constant variables with the values.
      • Check “getCost ()” is less than “LOWCOST”
        • Set “i” is “LOWINS”
      • Check “getCost ()” is less than “MEDCOST”
        • Set “i” is “MEDINS”
      • Otherwise, set “i” is “HIGHINS”
      • Call the “increaseCost()” method.

Filename: “Package.java”

  • Define the “Package” class
    • Declare the required private variables
    • Define the parameterized constructor
      • Set the values
      • Call the method
    • Define the “calculateCost” method
      • Declare the variable
      • Check “w” is less than “LOWWT”
        • Check “m” is equal to “AIR”
          • Set “c” is “LOWAIR”
        • Otherwise, check “m” is equal to “TRUCK”
          • Set “c” is “LOWTRUCK”
        • Otherwise, set “c” is “LOWMAIL”
            • Check “w” is less than “MEDWT”
              • Check “m” is equal to “AIR”
                • Set “c” is “MEDAIR”
              • Otherwise, check “m” is equal to “TRUCK”
                • Set “c” is “MEDTRUCK”
              • Otherwise, set “c” is “MEDMAIL”
            • Check “w” is less than “HIGHWT”
              • Check “m” is equal to “AIR”
                • Set “c” is “HIGHAIR”
              • Otherwise, check “m” is equal to “TRUCK”
                • Set “c” is “HIGHTRUCK”
              • Otherwise, set “c” is “HIGHMAIL”
            • Return the value
    • Define the “display” method
      • Display the result
    • Define the “getCost” method
      • Return the cost
    • Define the “increaseCost” method
      • Calculate the cost value

Filename: “UsePackage.java”

  • Define the “UsePackage” class
    • Define the main method
      • Create three objects for “Package” class with different values
      • Create three objects for “InsuredPackage” class with different values
      • Call the “display” method with different objects of “Package” and “InsuredPackage” classes.

Blurred answer
Students have asked these similar questions
Question 6 Create a set of classes and interface for the following scenario: Define an interface called Classical Music, which contains a get Year method that returns the year the classical album released. Create an abstract class Called CD. This class contains the title as String, and playingTime as integer (e.g. 60 minutes). Include a constructor to initialize all the data fields. Create an abstract method called printPlayingTime to show the CD playing details. Make sure all the data fields can be accessed directly from the child classes. Create a class called Album that inherits from the CD and Classical Music. Include a data field called year as integer type. Create a constructor to initialize all the data members. Override the getYear method to return the released year. Override the printPlayingTime method. If the CD title is more than 10 characters, this method will print the first 10 characters, followed by the three ellipse dots and the playing time. For example: Thriller 60…
Design a Ship class that the following members: A field for the name of the ship (a string). A field for the year that the ship was built (a string). A constructor and appropriate accessors and mutators. A toString method that displays the ship’s name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CruiseShip class’s toString method should display only the ship’s name and the maximum number of passengers. Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: A field for the cargo capacity in tonnage (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The…
Design a Ship class that has the following members:a. A field for the name of the ship (a string).b. A field for the year that the ship was built (a string).c. A constructor and appropriate accessors and mutators.d. A toString method that displays the ship's name and the year it was built.Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members:a. A field for the maximum number of passengers (an int).b. A constructor and appropriate accessors and mutators.c. A toString method that overrides the toString method in the base class. The CruiseShip class's toString method should display only the ship's name and the maximumnumber of passengers.Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members:a. A field for the cargo capacity in tonnage (an int).b. A constructor and appropriate accessors and mutators.c. A toString method that overrides the toString method in the base class. The…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY