Question
Somehow my math is coming in incorrect, but I can't figure out why. The output should have an amount due of $324.40, I am getting
Somehow my math is coming in incorrect, but I can't figure out why. The output should have an amount due of $324.40, I am getting $324. Can you please look at my Python code and tell me where my error is?
import sys ''' Section 1: Collect customer input '''
rentalCode = input("(B)udget, (D)aily, or (W)eekly rental? ") if rentalCode is 'B': rentalPeriod = int(input('Number of Days Rented: ')) elif rentalCode is 'D': rentalPeriod = int(input ('Number of Days Rented: ')) else: rentalPeriod = int(input('Number of Weeks Rented: '))
budget_charge = 40.00 daily_charge = 60.00 weekly_charge = 190.00
if rentalCode is 'B': baseCharge = int(rentalPeriod* budget_charge) elif rentalCode is 'D': baseCharge = int(rentalPeriod * daily_charge) else: rentalCode is 'W' baseCharge = int(rentalPeriod * weekly_charge)
odoStart = int(input('Starting Odometer Reading: ')) odoEnd = int(input('Ending Odometer Reading: ')) totalMiles = int(odoEnd)-int(odoStart)
if rentalCode is 'B': mileCharge = int(totalMiles * 0.25) elif rentalCode is 'D': averageDayMiles = int(totalMiles / rentalPeriod) if averageDayMiles < 100: extraMiles = 0 elif averageDayMiles > 100: extraMiles = int(averageDayMiles - 100) mileCharge = int(extraMiles * 0.25) elif rentalCode is 'W': averageWeekMiles = int(totalMiles / rentalPeriod) if averageWeekMiles < 900: extraMiles = 0 elif averageWeekMiles > 900: mileCharge = 100.00
amtDue = int(baseCharge + mileCharge)
amtDue = baseCharge + mileCharge print('Rental Summary') print('Rental Code:',rentalCode) print('Rental Period:',rentalPeriod) print('Starting Odometer:',odoStart) print('Ending Odometer:',odoEnd) print('Miles Driven:', totalMiles) print('Amount Due: '+'${:,.2f}'.format(amtDue))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started