Hi everyone. I'm reading through a beginners Python book and came up
with a super simple program. I'm not getting any errors and everything
runs through, but there's a logical calculation error. What the program
does is take an amount and calculate a couple percentages and add a
couple fees.
For example, if I put in a value of 1, it will output 752.12 as the sub
total and 753.12 as the grand total. It's off by 1 on sub total and 2 on
grand total.
Thanks in advance! Jim Gallaher
# Car Salesman Calculator
# User enters the base price of the car and the program adds tax,
license, dealer prep, and destination charge.
print("Car Sales Calculator")
basePrice = int(input("Please enter in the price of the car: "))
# Misc charges to be added to the total cost of the car
tax = basePrice * .07
license = basePrice * .05
dealerPrep = basePrice + 500
destinationCharge = basePrice + 250
# Add the total misc charges together
subTotal = float(tax + license + dealerPrep + destinationCharge)
# Add all the misic charges and include the base price
grandTotal = float(subTotal + basePrice)
# Display the results
print("\nThe sub total is", subTotal)
print("\nYour grand Total is", grandTotal)
input("\nPress the enter key to close the program.")
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor