Java Programming, Loose-leaf Version
Java Programming, Loose-leaf Version
8th Edition
ISBN: 9781337685917
Author: Joyce Farrell
Publisher: Cengage Learning
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
Explain Five reasons if computers should replace teachers. Provide three references with your answer. List three advantages and three disadvantages face to face learning and online learning may have on children. Provide two references with your answer.
You were requested to design IP addresses for the following network using the address block 10.10.10.0/24. Specify an address and net mask for each network and router interface
For the following network, propose routing tables in each of the routers R1 to R5

Chapter 10 Solutions

Java Programming, Loose-leaf Version

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
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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