C# Programming
The uPickItGrocery is a regional grocery store selling produce. They purchase their produce from the 4 farms below, with the corresponding shipment fee from each farm's state:
State/Farm Shipment Fee
NE - Northeast Farm 6.00%
NW - Northwest Farm 7.17%
SE - Southeast Farm 7.00%
SW - Southwest Farm 8.74%
They sell the following produce in all states:
Item Number Cost per Pound
10001 - Potatoes $7.87
10002 - Carrots $9.51
10003 - Tomatoes $10.73
10004 - Peppers $9.99
10005 - Eggplant $11.99
10006 - Onions $5.00
10007 - Garlic $4.58
Lastly, they have the following discount structure depending on the number of pounds of produce sold:
Pounds Discount
0-5 0%
6-10 5%
11-20 10%
21+ 15%
Our goal is to create an app allowing the user to input the order farm/state, the order item number, and the quantity in pounds, and return a price to the user. This price is the discounted price plus any relevant shipment fees. Thus, your calculation will be finding the total cost first (based on price and quantity/weight) and then the discount (based on quantity/weight) and using the discounted price to calculate the shipment fee. The total cost includes the discounted price and shipment fee.
Here are some hints for you:
Using a combo box will allow us to know the user has selected a valid state/farm if some value in the box is selected (refer to the examples below). Combo boxes can be found in the common controls section. To check for a selection, we check that the .SelectedIndex property is 0 or above (like arrays, index here starts at zero). We can retrieve the user's selected text through the .Text Property. The Items property controls what is in the box and is most easily set from the form designer (since it will be static for this program).
You are allowed to use magic numbers within your arrays to avoid an overload of constants. All other magic numbers require constants.
The item number can be checked as being between one thousand one and one thousand seven to simplify your code.
If written with ifs, this program would require at least 13 if statements. Therefore, loops and arrays are required.