Java Problem Statement

profilejehboy
Problem_Statement.pdf

BCIS 5390 Lab 04 Problem Statement 

Lab 4 will consist of modifying Lab 3 by implementing the following methods (provide a descriptive name for  each method based upon its purpose): 

 A value‐returning method that will receive the value of the package type and return the appropriate base  charge for the chosen package 

 A value‐returning method that will receive the value of the package type and the hours used and return  the additional charges for the chosen package 

 A value‐returning method that will receive the value of the first character of the zip code and return the  appropriate surcharge for the zip code entered 

 A value‐returning method that will receive the value of the base charge, additional charges, and  surcharge and return the subtotal for the chosen package 

 A value‐returning method that will receive the value of the county and return the appropriate discount  rate for that county 

 A value‐returning method that will receive the value of the subtotal and discount rate and return the  discount amount for the county entered 

 A value‐returning method that will receive the value of the subtotal and discount amount and return the  total charge for the chosen package 

 A void method that will receive the value of package type, county, zip code, base charge, additional  charge, surcharge, subtotal, discount amount, total charge average discount amount, and average total  charge and display each as shown in the sample output (NOTE: the package type, zip code, and county  should be embedded within the output statements) 

 A void method that will receive the hours used, package type, total charge, surcharge, and discount rate  and will display the amount of savings for Package B and Package C customers 

The static key word 

The static keyword indicates that a method or variable (often referred to as a field) belongs to the class not a  specific object. The static keyword can be used when declaring a variable (field) that can be accessed anywhere  within the class (scope) and retains its value as long as the program is running (lifetime). A common use for static  variables (fields) is for counters, accumulators, and named constants. Modify Lab 3 so that the named constants  for the cost of each package type and the counter and accumulators are declared as static including the private  access modifier. For example: 

  private static final double PACKAGE_A_COST = 9.95; 

  private static double totalOfDiscountAmount = 0; 

  private static int totalOfCustomers = 0; 

These variables (fields) should be declared within the class, but outside any of the methods. Traditionally just  under the class header. 

 Incrementing of counter, accumulators, and calculation of average may remain in the main method   All monetary output should be formatted the DecimalFormat class or String.Format to display as currency 

(i.e., leading dollar sign, appropriate comma(s), and two‐decimal places). 

 Use the horizontal tab escape sequence to format output to line up appropriately (see Table 2.2, p. 37).   The newline escape sequence can be used to format spacing between output (see Table 2.2, p. 37). 

Sample input/output has been provided on the next page. 

Sample #1 Enter hours used: 25 Enter zip code: 76401 Enter county: Erath Enter package type: A Base Charge for Package A: $9.95 Additional Charge for Package A: $30.00 Surcharge for Zip Code - 76401: $0.00 Subtotal for Package A: $39.95 Discount Amount for ERATH County: $7.99 Total Charge for Package A: $31.96 Package B Savings: $16.80 Package C Savings: $16.00 Total Discount Amount for All Packages: $7.99 Total Charge for All Packages $31.96 Average Discount Amount: $7.99 Average Total Charge: $31.96 Total Customers: 1 Sample #2 Enter hours used: 25 Enter zip code: 56789 Enter county: Parker Enter package type: B Base Charge for Package B: $13.95 Additional Charge for Package B: $5.00 Surcharge for Zip Code - 56789: $1.75 Subtotal for Package B: $20.70 Discount Amount for PARKER County: $2.07 Total Charge for Package B: $18.63 Total Discount Amount for All Packages: $10.06 Total Charge for All Packages $50.59 Average Discount Amount: $5.03 Average Total Charge: $25.30 Total Customers: 2 Sample #3 Enter hours used: 50 Enter zip code: 76401 Enter county: Erath Enter package type: C Base Charge for Package C: $19.95 Surcharge for Zip Code - 76401: $0.00 Subtotal for Package C: $19.95 Discount Amount for ERATH County: $3.99 Total Charge for Package C: $15.96 Total Discount Amount for All Packages: $14.05 Total Charge for All Packages $66.55 Average Discount Amount: $4.68 Average Total Charge: $22.18 Total Customers: 3 Sample #4 Enter hours used: 5 Enter zip code: 12345 Enter county: Winkler Enter package type: A Base Charge for Package A: $9.95 Surcharge for Zip Code - 12345: $0.00 Subtotal for Package A: $9.95 Discount Amount for WINKLER County: $0.00 Total Charge for Package A: $9.95 Total Discount Amount for All Packages: $14.05 Total Charge for All Packages $76.50 Average Discount Amount: $3.51 Average Total Charge: $19.12 Total Customers: 4 Enter hours used: -1 Good-bye!