
please wait
You have the choice of buying two cars. One is more fuel efficient than the other, but also more expensive. You know the price and fuel efficiency (in miles per gallon, mpg) of both cars. You plan to keep the car for ten years. Assume a price of $4 per gallon of gas and usage of 15,000 miles per year. You will pay cash for the car and not worry about financing costs. Which car is the better deal? |
#include<iostream>; using namespace std; int main () int (purchase price 1); int (purchase price 2); int (fuel efficiency 1); int (fuel efficiency 2 cout<<"Insert the price of the first car" <<endl; cin>>purchase price 1; cout<<"Insert the price of the fuel efficiency of the first car"<<endl; cin>>fuel efficiency 1; cout<<"Insert the price of the second car"<<endl; cin>>purchase price 2; cout<<"Insert the price of the fuel efficiency of the second car"<<endl; cin>>fuel efficiency 2; {annual fuel cost 1=4*annual fuel consumed 1; annual fuel cost 2=4*annual fuel consumed 2;} {annual fuel consumed 1=10000/fuel efficiency 1; annual fuel consumed 2=10000/fuel efficiency 2;} {operating cost 1=10*annual fuel cost 1; operating cost 2=10*annual fuel cost 2;} {total cost 1=purchase price 1+operating cost 1; total cost 2=purchase price 2+operating cost 2;} If { total cost 1 < total cost 2 cout<<"Choose first car"; else cout<<"Choose second car"; } return 0; |