Write a program that helps a person decide whether to buy a hybrid car. Your pro
ID: 3808969 • Letter: W
Question
Write a program that helps a person decide whether to buy a hybrid car. Your program's inputs should be: The make/model of the vehicle the cost of a new vehicle the estimated miles driven per year the estimated gas price The average miles per gallon Compute the total cost of owning the vehicle for five years including the cost of the vehicle. (For simplicity, we will not take the cost of financing into account, nor will we consider selling the vehicle.) Obtain realistic prices for a new hybrid car and another new vehicle from the Web, so that you can compare two venires. The total cost should be output with only two decimal places. Make sure to include step comments in your program and header comments as follows: Program name: ?????. Programmer: Your Name Date created: 1/27/2016 Purpose: Write a sentence (or a few sentences) that describe the purpose of this program. Save your program and submit your. file in Blackboard. What is the make/model of the vehicle? 2015 Toyota Cost of this brand-new vehicle? 26815 Miles driven per year? 23000 Price of gas (per gallon)? 2.39 Average miles per gallon? 48 Total cost for 5 years is $ 32541.04 What is the make/model of the vehicle? 2015 Dodge RAM 1500 Cost of this brand-new vehicle? 25660 Miles driven per year? 23000 Price of gas (per gallon)? 2.39 Average miles per gallon? 17 Total cost for 5 years is $ 41827.65Explanation / Answer
Python 2.7 code:
print "What is the make/model of the vehicle?"
name = raw_input().strip();
print "Cost of this brand new vehicle?"
main_cost = float(raw_input().strip())
print "Miles driven per year?"
Miles_per_year = float(raw_input().strip())
print "Price of gas per gallon?"
price_per_gallon = float(raw_input().strip())
print "Average miles per gallon?"
Miles_per_Gallon = float(raw_input().strip())
total_price = main_cost + 5*(Miles_per_year*(1/Miles_per_Gallon)*price_per_gallon)
print " Total cost for 5 years is $ ", round(total_price,2)
Sample Output:
C:UsersAkashDesktopchegg>python simple.py
What is the make/model of the vehicle?
2012 dogde RAM 1500
Cost of this brand new vehicle?
25660
Miles driven per year?
23000
Price of gas per gallon?
2.39
Average miles per gallon?
17
Total cost for 5 yearsis $ 41827.64
C:UsersAkashDesktopchegg>python simple.py
What is the make/model of the vehicle?
2015 TOYOTA Prius
Cost of this brand new vehicle?
26815
Miles driven per year?
23000
Price of gas per gallon?
2.39
Average miles per gallon?
48
Total cost for 5 years is $ 32541.04
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.