Question
IN C# If It Fits, It Ships! OVERVIEW In this program you will be calculating the total amount the user will owe to ship a
IN C#
If It Fits, It Ships!
OVERVIEW In this program you will be calculating the total amount the user will owe to ship a
rectangular package based on the dimensions and we will add in insurance based on the prices of the items inside of the package..
INSTRUCTIONS:
Welcome the user and explain the purpose of the program.
In the Main, prompt the user for the width, length and height of their package.
a. Each of the 3 variables should be validated and converted.
3. Create a custom function called SortByDimensions a. This function needs 3 parameters: the width, length and height. b. The function will be returning the number of what tier pricing is going to be used. c. Inside of the function, use a series of conditionals and logical operators to
determine the tier based on the chart below. d. Return this integer of the matching tier to the main.
i. Make sure to catch this in a variable of the correct type.
Back in the Main, let the user know what Tier for dimensions the package is.
In the Main, prompt the user for a comma separated text string of the prices of each item in the package.
Remind the user NOT to put in the $. i. I.e. 5.60, 9.99, 10.50
Validate that this text string is not left blank.
Once you have this text string, split about this string into a string array.
Each element should be one price of an item.
6. Create a custom function called CalcInsurance. a. This function needs a parameter of the string array of item prices. b. The function will return the cost of the insurance for the package. c. Inside of this function a variable that will hold the total cost of all of the items. d. You will also need a variable to hold the cost of the insurance. e. Loop through the item string array and one at a time, convert each item to a
number data type i. Add this price to the variable that holds the total cost.
ii. After the loop, you should have a variable that holds the total of all items inside the package.
f. Use the chart below to setup a conditional block that will give you the cost of the Insurance for this package.
g. Return this cost of insurance to the Main. i. Make sure to catch this in a variable of the correct type.
7. Create a 3rd custom function called TotalShippingCost.
This function will have 2 parameters: the tier number based on the dimensions
and the total cost of the insurance.
The function will return the total of the shipping cost.
In the function create a conditional block the will set the shipping base cost.
i. This will be based on the chart below.
Once you have the base price, add in the insurance to create the total shipping
cost.
Return this total for the shipping to the Main.
i. Make sure to catch this in a variable of the correct type.
8. Now in the Main you will output to the user the final results. a. It should be in the following format.
i. Your package will cost $X to ship, which includes the $Y insurance price.
Where X is the total cost to ship the package formatted for money and rounded to 2 decimal places.
Where Y is the insurance cost formatted for money and rounded to 2 decimal places.
9. Test, Test, Test
Test your code at the very least 2 times and put your Test Results in a multi-lined
comment at the end of your Main Method.
Here is one data set that you should test with to make sure your math is correct.
i. Package Dimensions:
1. 2. 3. 4.
ii. Prices 1. 2.
Width = 5 Length = 12 Height =2 For troubleshooting you could check the Tier # is 2.
of items in package: 50.50, 25.00, 6.00, 150.00 For troubleshooting you could check the total is 231.50.
iii. Final Output should be: 1. Your package will cost $20.50 to ship, which includes the $5.00
insurance price.
TIER # Requirements All dimensions must be 10" and under 2 Largest of the dimension is between 10" and 48 Largest of the dimensions is 48" or above
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started