In How To 1.1, you made assumptions about the price of gas and annual usage to compare cars. Ideally, you would like to know which car is the better deal without making these assumptions. Why can’t a computer program solve that problem?
belongs to collection: Algorithm and pseudocode excersices
All Answers
total answers (1)
The Answer:
// Inputs are one way distance, beginning mileage, ending mileage, number of work days
need an explanation for this answer? contact us directly to get an explanation for this answer// Question asks only for fraction "commuting to work" thus we don't need to count the fraction commuting back home
total miles traveled = ending mileage - beginning mileage
miles traveled to work = one way distance * number of work days
// This is what we want to know:
fraction of miles for commute = miles traveled to work / total miles traveled
// Personal use is whatever is left over
fraction of miles for personal use = 1 - fraction of miles for commute