Java Programming
Java Programming
8th Edition
ISBN: 9781305981829
Author: Joyce Farrell
Publisher: Cengage Limited
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
HistogramUse par(mfrow=c(2,2)) and output 4 plots with different argument settings.
(use R language)Scatter plot(a). Run the R code example, and look at the help file for plot() function. Try different values for arguments:type, pch, lty, lwd, col(b). Use par(mfrow=c(3,2)) and output 6 plots with different argument settings.
1. Draw flow charts for each of the following;a) A system that reads three numbers and prints the value of the largest number.b) A system reads an employee name (NAME), overtime hours worked (OVERTIME), hours absent(ABSENT) and determines the bonus payment (PAYMENT).
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