fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main() {
  6. // Variables for monthly expenses
  7. double loanPayment, insurance, gas, oil, tires, maintenance;
  8. double totalMonthly, totalAnnual;
  9.  
  10. // Ask the user for each expense
  11. cout << "Enter your monthly loan payment: $";
  12. cin >> loanPayment;
  13.  
  14. cout << "Enter your monthly insurance cost: $";
  15. cin >> insurance;
  16.  
  17. cout << "Enter your monthly gas cost: $";
  18. cin >> gas;
  19.  
  20. cout << "Enter your monthly oil cost: $";
  21. cin >> oil;
  22.  
  23. cout << "Enter your monthly tires cost: $";
  24. cin >> tires;
  25.  
  26. cout << "Enter your monthly maintenance cost: $";
  27. cin >> maintenance;
  28.  
  29. // Calculate totals
  30. totalMonthly = loanPayment + insurance + gas + oil + tires + maintenance;
  31. totalAnnual = totalMonthly * 12;
  32.  
  33. // Display results
  34. cout << fixed << setprecision(2);
  35. cout << "\n===== Automobile Expenses Report =====" << endl;
  36. cout << "Total Monthly Cost: $" << totalMonthly << endl;
  37. cout << "Total Annual Cost: $" << totalAnnual << endl;
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0.01s 5316KB
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