Tino APCS

Lab 8.1 CheckMail

Background

The U.S. post office has rules about mailing packages. A package cannot be mailed first class if the sum of its length and girth is greater than 100 inches, or if the package weighs more than 70 pounds.

Girth is the perimeter around the height and width, where the length is defined as the longest of the three dimensions.

Here is a visual representation of girth:

Assignment

Write a program that takes in the weight of the package and the three dimensions of the package in any order. (You may put all your code in the main() method.) The program should determine the longest dimension of the package, calculate the girth, and compute the size of the box. The program should then print out one of the following messages about this package:

  1. Package is too large and too heavy.
  2. Package is too large.
  3. Package is too heavy.
  4. Package is acceptable.

Let’s look at how to design this class.

Stepwise refinement 1 - Overall sections of this problem:

  • Get data from user
  • Solve math
  • Print answer

Stepwise refinement 2 - More detailed pseudocode version:

  • Prompt user for three dimensions
  • Prompt user for weight

  • Determine longest of three dimensions

  • Calculate the girth using the other two dimensions

  • if package is too big and too heavy, print appropriate message

  • else if package is too big, print appropriate message
  • else if package is too heavy, print appropriate message
  • else print package is acceptable

Requirements

  • Do all your work in the main() method.
  • The user can enter the 3 dimensions in any order so you need to work out which is the largest regardless of the order they entered the dimensions in.
  • There are four distinct cases for possible package types. Make sure you've tested your code and that it works for all the cases. The cases are shown below.
  • The program should print out exactly one of the following messages about any given package:
  1. Package is too large and too heavy.
  2. Package is too large.
  3. Package is too heavy.
  4. Package is acceptable.

Submission directions

Name your class PX_LastName_FirstName_CheckMail and submit it below.

You must Sign In to submit to this assignment

Dark Mode

Outline