Programming Challenge Chapter 3 – Q #9 Automobile Costs – Tony Gaddis – Starting Out With C++
Problem: -
Solution: -
#include <iostream>
using namespace std;
int main()
{
int loan, gas, oil, insurance, tires, maintainance;
int annual_expendature = 0, monthly_expendature = 0;
cout << "This Program
Calculate AutoMobile Cost, Enter Required Data\n";
cout << "Enter Loan
Ammount: $";
cin >> loan;
cout << "Enter Insurance
Ammount: $";
cin >> insurance;
cout << "Enter Tires
Cost: $";
cin >> tires;
cout << "Enter Oil Cost: $";
cin >> oil;
cout << "Enter Gas Cost: $";
cin >> gas;
cout << "Enter Maintainance
Cost: $";
cin >> maintainance;
monthly_expendature = loan + insurance + tires + oil + gas +
maintainance;
annual_expendature = monthly_expendature * 12;
cout << "\nMonthly Automobile
Cost is " << monthly_expendature << endl;
cout << "Annual Automobile
Cost is " << annual_expendature;
return 0;
}
This is the solution of this question
OUTPUT OF THIS QUESTION
Input is highlighted with yellow color.
Explanation of this Solution
- Declare six int variables for input.
- Declare two int variable for calculation.
- Take input one by one from the user by using cin.
- Calculate the value of cost.
- In last, display output on the screen.
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments