> On Dec 12, 2015, at 2:03 AM, Jim Gallaher <[email protected]> wrote:
>
> 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
>
I think your main problem is right here. Why do dealerPrep and
destinationCharge include the basePrice in their equation? This will add the
basePrice in multiple times. I would simply set it like this:
dealerPrep = 500
destinationCharge = 250
If these charges ever change, you can put in some sort of equation. However, it
looks like these are meant to be a flat fee.
> # Add the total misc charges together
> subTotal = float(tax + license + dealerPrep + destinationCharge)
>
> # Add all the misic charges and include the base pricem
> 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 - [email protected]
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor