Nov-27-2019, 06:31 PM
Hi everyone,
I'm working on a homework assignment to write a script to output the next major oil change and maintenance needed for a car. I've tried a ton of different ways of doing this, but can't get it to display the next 5 oil changes and next 3 major maintenance needs. I've managed an endless loop, I've managed to get it to repeat and display every number from the current mileage and 30000, but not what I need! As it is now, it is just getting the input, but not displaying any calculations.
Any ideas?
I'm working on a homework assignment to write a script to output the next major oil change and maintenance needed for a car. I've tried a ton of different ways of doing this, but can't get it to display the next 5 oil changes and next 3 major maintenance needs. I've managed an endless loop, I've managed to get it to repeat and display every number from the current mileage and 30000, but not what I need! As it is now, it is just getting the input, but not displaying any calculations.
Any ideas?
# This is a program that displays the maintenance schedule for a car # Defining global constants of oil change and major maintenance OIL_CHANGE_NEEDED = 3000 MAJOR_MAINTENANCE_NEEDED = 30000 # main function def main(): # get current mileage current_mileage = int(input("What is your car's current mileage?")) # display the oil change mileages display_oil_change(current_mileage) # display the major maintenance needed display_major_maintenance(current_mileage) #Display mile reading for next 5 oil changes def display_oil_change(mileage): end = int(input("How many oil changes would you like to know?")) for oil_change in range(mileage, end, OIL_CHANGE_NEEDED): print ("Your next oil change will be in", oil_change) # Display mile reading for next 3 major maintenance needs def display_major_maintenance(mileage): end = int(input("How many maintenance appointments would you like to know?")) for maintenance in range(mileage, end, MAJOR_MAINTENANCE_NEEDED): print ('Your next major maintenance will be in', maintenance) main()