Programming Homework Help
BCIS 5390 Tarleton State University Chapter 3 Decision Structure Python Lab
Activity Details
Perform the following tasks:
- Step 1: Create a Python (.py) file using IDLE (see Appendix B – Introduction to IDLE) using the required naming convention for Lab 03: CourseNumber_LastNameFirstInitial_LabNumber (e.g., 5390_SharpJ_Lab03)
Place the required identification information in Comment statements (see Section 2.4 Comments on page 39) at the top of the Python program. Within the body of the program implement the following requirements as described in the problem statement below:
Fast Freight Shipping Company has hired you to create a program which calculates and displays the shipping charge information for packages based upon the weight of the package and the state to which it is being shipped.
The current shipping rates per pound are provided below:
Weight of PackageRate Per Pound2 pounds or less$1.50Over 2 pounds but not more than 6 pounds$3.00Over 6 pounds but not more than 10 pounds$4.00Over 10 pounds$4.75
The Fast Freight Shipping Company has a limited geographic shipping area and only ships to locations in Arkansas (AR), Kansas (KS), Louisiana (LA), New Mexico (NM), Oklahoma (OK), and Texas (TX). The state sales tax rate for each is provided below (assume these values are constant while the program is running):
State AbbreviationState Sales Tax Rate
AR6.50%KS6.50%LA5.00%NM5.125%OK4.50%TX6.25%
The program should allow the user to enter the weight of the package (assume floating-point values may be entered) and the state abbreviation to which it will be shipped (assume state abbreviation may be entered in all lowercase or all uppercase or mixed case – see Table 8-2 on page 422 for converting to lower case or upper case for evaluation and display purposes). The program should then determine/calculate and display the rate per pound, the shipping charge, the state abbreviation, the state sales tax rate, the state sales tax, and the total shipping charge.
Validation:
If a value less than or equal to 0 is entered for the weight of the package, the program should display an error message such as “Invalid entry. Weight of the package must be greater than zero.” and the program should end. The program should not prompt the user for the state if the weight of the package is invalid.
If a value that does not match one of the specific states to which Fast Freight Shipping Company ships is entered, the program should display an error message such as “Invalid entry. State must be AR, KS, LA, NM, OK, or TX, and the program should end.
General Requirements:
- Variable names MUST follow the naming rules (see page 43), be descriptive, and follow a standard naming convention, such as the textbook naming convention where multiple words are separated by underscores, commonly used by Python programmers (i.e, gross_pay) or camelCase convention (i.e., grossPay).
- Named constants MUST use the standard naming convention provided in the textbook of all uppercase letters with multiple words separated by underscores.
- Comment statements MUST be included for each major section of code to provide a brief description of its purpose. For example, at the beginning of the input statements, at the beginning of a decision structure, at the beginning of calculations, or output statements, etc. Single-line comments are adequate.
- All output values representing currency should be displayed with $ and two decimal places (see Program 2-21 on page 70).
- All output value(s) representing a percentage should be displayed with % and three decimal places (see example on page 72).
Sample Scenarios:
1. User enters -5 for weight of package:
Enter the weight of the package: -5
Invalid entry. Weight of package must be greater than zero.
2. User enters 0 for weight of package:
Enter the weight of the package: 0
Invalid entry. Weight of package must be greater than zero.
3. User enters 2 for weight of package and WY for state abbreviation:
Enter the weight of the package: 2
Enter the state abbreviation to ship to: WY
Invalid entry. State abbreviation must be AR or KS or LA or NM or OK or TX.
4. User enters 2 for weight of package and LA for state abbreviation:
Enter the weight of the package: 2
Enter the state abbreviation to ship to: LA
SHIPPING SUMMARY
The rate per pound is $1.50
The shipping charge is $3.00
The state to be shipped to is LA
The state sales tax rate is 5.000%
The state sales tax is $0.15
The total shipping charge is $3.15
5. User enters 6 for weight of package and ok for state abbreviation:
Enter the weight of the package: 6
Enter the state abbreviation to ship to: ok
SHIPPING SUMMARY
The rate per pound is $3.00
The shipping charge is $18.00
The state to be shipped to is OK
The state sales tax rate is 4.500%
The state sales tax is $0.81
The total shipping charge is $18.81
6. User enters 10 for weight of package and Ar for state abbreviation:
Enter the weight of the package: 10
Enter the state abbreviation to ship to: Ar
SHIPPING SUMMARY
The rate per pound is $4.00
The shipping charge is $40.00
The state to be shipped to is AR
The state sales tax rate is 6.500%
The state sales tax is $2.60
The total shipping charge is $42.60
7. User enters 25 for weight of package and tx for state abbreviation:
Enter the weight of the package: 25
Enter the state abbreviation to ship to: tx
SHIPPING SUMMARY
The rate per pound is $4.75
The shipping charge is $118.75
The state to be shipped to is TX
The state sales tax rate is 6.250%
The state sales tax is $7.42
The total shipping charge is $126.17
8. User enters 1000 for weight of package and nM for state abbreviation:
Enter the weight of the package: 1000
Enter the state abbreviation to ship to: nM
SHIPPING SUMMARY
The rate per pound is $4.75
The shipping charge is $4,750.00
The state to be shipped to is NM
The state sales tax rate is 5.125%
The state sales tax is $243.44
The total shipping charge is $4,993.44
- Step 3: Run the program and correct any syntax/logic errors.