fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <string>
  5. #include <cstdlib>
  6.  
  7. using namespace std;
  8. const int MAX_NAME_LEN = 10;
  9.  
  10. int main() {
  11. int numberOfMonths = 11;
  12. int beginningMonth = 1;
  13. int endingMonth = 12;
  14.  
  15. // Print the heading for the table.
  16. // Pre: All "IN" parameters have correct values.
  17. // Post: The table title, column headings, and a separator line
  18. // will be printed to stdout.
  19. int month = beginningMonth; // Current month to be printed
  20.  
  21. // Print table title and title of product column
  22. cout << "Monthly Cost of Bakery Products Forecast" << endl << endl;
  23. cout << left;
  24. cout << setw(MAX_NAME_LEN + 1) << "Product";
  25.  
  26. // TODO:...REPLACE WITH FINISHED CODE...
  27. for (int month = 0; month<numberOfMonths; month++) {
  28. cout << right << setw(8) << month+1;
  29. }
  30.  
  31. cout << endl;
  32. cout << right;
  33. cout << string(MAX_NAME_LEN+1, '-') << "+";
  34. for (int month = 0; month<numberOfMonths; month++) {
  35. cout << right << string(7, '-') << "+";
  36. }
  37. cout << endl;
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0s 4268KB
stdin
Standard input is empty
stdout
Monthly Cost of Bakery Products Forecast

Product           1       2       3       4       5       6       7       8       9      10      11
-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+