fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. void p(string text, float amount) {
  8. cout << left << setw(20) << text << " $ " << right << setw(8) << amount << endl;
  9. }
  10.  
  11. int main() {
  12.  
  13. float total, cstax, sstax, tstax, sale;
  14. int year;
  15. string month;
  16.  
  17. cout << "Please Enter Month:";
  18. cin >> month;
  19.  
  20. cout << "Please Enter year:";
  21. cin >> year;
  22.  
  23. cout << "Please Enter Total:";
  24. cin >> total;
  25.  
  26. sale = total / 1.06;
  27. cstax = 0.02 * sale;
  28. sstax = 0.04 * sale;
  29. tstax = 0.06 * sale;
  30.  
  31. cout << setprecision(2) << fixed;
  32.  
  33. cout << endl << "Month: " << month << " " << year << endl;
  34. cout << "---------------------------------" << endl;
  35. p("Total Collected:", total);
  36. p("Sales:", sale);
  37. p("County Sales Tax:", cstax);
  38. p("State Sales Tax:", sstax);
  39. p("Total Sales Tax:", tstax);
  40.  
  41. return 0;
  42. }
  43.  
  44.  
Success #stdin #stdout 0s 4364KB
stdin
March
2008
26572.89
stdout
Please Enter Month:Please Enter year:Please Enter Total:
Month: March 2008
---------------------------------
Total Collected:       $ 26572.89
Sales:                 $ 25068.77
County Sales Tax:      $   501.38
State Sales Tax:       $  1002.75
Total Sales Tax:       $  1504.13