How do i Create a program that determine the shipping cost for an order based on the following table:
From To Price
$0.00 $19.00 $2.95
$20.00 $49.99 $3.95
$50.00 $74.99 $4.95
$75.00 $1000.00 $Free
I don't understand how to do this...Would anyone please help create a program please?
Sure! I'd be happy to help you create a program to determine the shipping cost for an order based on the given table.
To create the program, we will need a programming language. In this example, let's use Python. You can start by opening a text editor and creating a new file with a .py extension (e.g., shipping_cost.py).
First, we need to define the function that determines the shipping cost based on the order's total price. Here's a sample code:
```python
def calculate_shipping_cost(total_price):
if total_price >= 0 and total_price < 20:
shipping_cost = 2.95
elif total_price >= 20 and total_price < 50:
shipping_cost = 3.95
elif total_price >= 50 and total_price < 75:
shipping_cost = 4.95
else:
shipping_cost = 0.00
return shipping_cost
```
In this code, we use if-elif-else statements to check the range of the total_price and assign the appropriate shipping cost accordingly. For any total_price value that falls outside the defined ranges, the shipping cost will be set to $0.00 (free).
Next, we can test the function by calling it with a total_price value and printing the result. Here's an example:
```python
# Test the function
order_total = 25.00
shipping = calculate_shipping_cost(order_total)
print(f"The shipping cost for an order of ${order_total:.2f} is ${shipping:.2f}.")
```
In this example, we assume the order_total is $25.00. We pass this value to the `calculate_shipping_cost` function, store the returned shipping cost in the `shipping` variable, and print the result using string formatting.
Save the file, and you can run the program by executing the Python code in a terminal or using an integrated development environment (IDE) for Python.
When you run the program, you should see the output:
```
The shipping cost for an order of $25.00 is $3.95.
```
That's it! You have successfully created a program to determine the shipping cost based on the provided table. Feel free to modify the code to suit your needs and add any additional functionalities if required.