(Aug-24-2024, 02:31 AM)deanhystad Wrote: Next time post code instead of attaching text file. You should also post the instructions. I assume there is a 7% delivery charge, a 15% discount on pizza orders > 15 pizzas, and a 15% discount on salad orders > 10 salads. At least that is what your code says. Seems like there would be a discount of 15% on 10 items or more, but that is not what your code does. And should the delivery fee be calculated on the discounted or non-discounted cost.?
The feedback from the autograder does not match your program. I don't think the code you posted is the code that generated the feedback from the autograder. Nowhere does your program print the number of salads ordered. Nor does the output from the autograder match with the input (43 and 7 are input. Neither == 11).
This is the exact code that I put into the autograder.
# List inputs so user can enter values
p = float(input("Number of pizza orders "))
s = float(input("Number of salad orders "))
# Calculates pizza cost, salad cost, total cost of pizza and salad combined, delivery charge, total amount , and the discount.
pizza_cost: float = (p * 15.99)
salad_cost: float = (s * 7.99)
total_cost: float = (pizza_cost + salad_cost)
delivery_charge: float = (7 / 100 * total_cost)
discount: float = 0
# Both of these if statements allow the discount to be applied on orders over 10 pizzas. It updates the variable to an actual discount.
if p > 10:
pizza_discount1: float = (15 / 100 * pizza_cost)
discount += pizza_discount1
if s > 10:
salad_discount1: float = (15 / 100 * salad_cost)
discount += salad_discount1
# This if statement puts a minimum of $20 on delivery orders if 7% is under $20, and leaves it alone if delivery fee above $20.
if delivery_charge < 20:
delivery_charge = 20
#Calculate total amount due
total_amount: float = (total_cost - discount + delivery_charge)
print("Ordered:",p)
print("Pizza cost $",pizza_cost)
print("Salad cost $",salad_cost)
print("Total $",total_cost)
print("Discount $",discount)
print("Delivery $",delivery_charge)
print("Total amount $",total_amount)