fork(2) download
  1. // Nicolas Ruano CS1A Chapter 3, Pp.
  2. /*******************************************************************************
  3.  * AUTOMATION COSTS
  4.  * ____________________________________________________________________________
  5.  * This programs demostrates the mathematical procedure of each cost of the
  6.  * Automation costs.
  7.  * ____________________________________________________________________________
  8.  * MONTHLY EXPENSES
  9.  * How much cost for:
  10.  * monthly loan
  11.  * montly insurance
  12.  * monthly gas
  13.  * oil
  14.  * tires
  15.  * monthly maintance
  16.  * ____________________________________________________________________________
  17.  * CALCULATING THE TOTAL
  18.  * totalMonthly = loanPayment + insurance + gas + oil + tires + maintenance;
  19.  * totalAnnual = totalMonthly * 12
  20.  * ____________________________________________________________________________
  21.  * THE RESULTS GIVEN IN THE END
  22.  * "\n===== Automobile Expenses Report ====="
  23.  * "Total Monthly Cost: $"
  24.  * "Total Annual Cost: $"
  25. *******************************************************************************/
  26. #include <iostream>
  27. #include <iomanip>
  28. using namespace std;
  29.  
  30. int main() {
  31. // Variables for monthly expenses
  32. double loanPayment, insurance, gas, oil, tires, maintenance;
  33. double totalMonthly, totalAnnual;
  34.  
  35. // Ask the user for each expense
  36. cout << "Enter your monthly loan payment: $";
  37. cin >> loanPayment;
  38.  
  39. cout << "Enter your monthly insurance cost: $";
  40. cin >> insurance;
  41.  
  42. cout << "Enter your monthly gas cost: $";
  43. cin >> gas;
  44.  
  45. cout << "Enter your monthly oil cost: $";
  46. cin >> oil;
  47.  
  48. cout << "Enter your monthly tires cost: $";
  49. cin >> tires;
  50.  
  51. cout << "Enter your monthly maintenance cost: $";
  52. cin >> maintenance;
  53.  
  54. // Calculate totals
  55. totalMonthly = loanPayment + insurance + gas + oil + tires + maintenance;
  56. totalAnnual = totalMonthly * 12;
  57.  
  58. // Display results
  59. cout << fixed << setprecision(2);
  60. cout << "\n===== Automobile Expenses Report =====" << endl;
  61. cout << "Total Monthly Cost: $" << totalMonthly << endl;
  62. cout << "Total Annual Cost: $" << totalAnnual << endl;
  63.  
  64. return 0;
  65. }
  66.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Enter your monthly loan payment: $Enter your monthly insurance cost: $Enter your monthly gas cost: $Enter your monthly oil cost: $Enter your monthly tires cost: $Enter your monthly maintenance cost: $
===== Automobile Expenses Report =====
Total Monthly Cost: $0.00
Total Annual Cost:  $0.00