|Assignment: #CommuteCalculator||Due: 04/15/2017||Points: 5|
This program calculates the cost of a commute. The calculation requires the following inputs.
- how many round-trip miles a day do you commute
- how many days a week do you commute
- how many weeks a year do you commute
- what is the gas mileage of your vehicle (i.e. miles per gallon)
- what is the current per gallon price of gas
Prompt the user to enter the aforementioned data and compute how much money per month is spent on gas.
intvariables for all the data except for the price of gas -- use a
doubleto store that.
The formula for this part is similar to the following:
- determine the milesPerYear
(milesPerDay multiplied by daysPerWeek multiplied by weeksPerYear)
- determine gallonsPerYear
(milesPerYear divided by milesPerGallon)
- determine gasMoneyPerYear
(gallonsPerYear times pricePerGallon)
- determine monthlyGasExpense
(gasMoneyPerYear divided by the number of months in a year)
Note: Numbers enclosed in <
angle brackets> are user inputs. Your prompts should match those used in this example.How many miles round-trip a day do you commute? <22> How many days a week do you commute? <4> How many weeks a year do you commute? <39> How many miles per gallon does your vehicle get? <23> What is the current per gallon price of gas? <1.21>
The program output should look as follows.22 miles a day 4 days a week 39 weeks a year 23 miles per gallon $1.21 per gallon monthly gas expense: $15.0461
Prompt the user if they'd like to do another cost of commute calculation. If they enter 'Y' or 'y', then repeat; otherwise, print the following and exit the program.This program executed X cost of commute calculations. Total commute miles: Y Average commute cost: $z