fork download
  1. /*
  2.  * PROGRAMMED BY : Jacob Silvestre
  3.  * CLASS : CSC5
  4.  * SECTION : MW - 2:20 - 6:30p
  5.  * ASSIGNMENT #1 : Basic Input / Output
  6.  */
  7.  
  8. #include <iostream>
  9. #include <iomanip>
  10. #include <string>
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. // Constants
  16. const int NUM_PEOPLE = 3;
  17. const double MONTHS_PER_YEAR = 12.0;
  18. const double RETRO_MONTHS = 6.0;
  19.  
  20. // Variables
  21. string name;
  22. double currentSalary;
  23. double payIncrease;
  24. double newSalary;
  25. double monthlySalary;
  26. double retroactivePay;
  27.  
  28. // Class heading
  29. cout << "****************************************************" << endl;
  30. cout << "* PROGRAMMED BY : Jacob Silvestre" << endl;
  31. cout << "* CLASS : CSC5" << endl;
  32. cout << "* SECTION : MW - 2:20 - 6:30p" << endl;
  33. cout << "* ASSIGNMENT #1 : Basic Input / Output" << endl;
  34. cout << "****************************************************" << endl;
  35. cout << endl;
  36.  
  37. for (int count = 1; count <= NUM_PEOPLE; count++)
  38. {
  39. // Input
  40. cout << "What is your name? ";
  41. getline(cin, name);
  42.  
  43. cout << "What is your current salary? ";
  44. cin >> currentSalary;
  45.  
  46. cout << "What is your pay increase? ";
  47. cin >> payIncrease;
  48.  
  49. // Calculations
  50. newSalary = currentSalary + (currentSalary * payIncrease);
  51.  
  52. monthlySalary = newSalary / MONTHS_PER_YEAR;
  53.  
  54. retroactivePay =
  55. (newSalary - currentSalary) /
  56. MONTHS_PER_YEAR * RETRO_MONTHS;
  57.  
  58. // Output
  59. cout << endl;
  60. cout << name << "'s SALARY INFORMATION" << endl;
  61.  
  62. cout << left
  63. << setw(20) << "New Salary"
  64. << setw(20) << "Monthly Salary"
  65. << setw(20) << "Retroactive Pay"
  66. << endl;
  67.  
  68. cout << fixed << setprecision(2);
  69.  
  70. cout << right
  71. << setw(10) << newSalary
  72. << setw(20) << monthlySalary
  73. << setw(20) << retroactivePay
  74. << endl;
  75.  
  76. cout << endl;
  77. cout << "<Press enter to continue>";
  78.  
  79. cin.ignore();
  80. cin.get();
  81.  
  82. cout << endl << endl;
  83. }
  84.  
  85. return 0;
  86. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
****************************************************
*  PROGRAMMED BY : Jacob Silvestre
*  CLASS         : CSC5
*  SECTION       : MW - 2:20 - 6:30p
*  ASSIGNMENT #1 : Basic Input / Output
****************************************************

What is your name? What is your current salary? What is your pay increase? 
's SALARY INFORMATION
New Salary          Monthly Salary      Retroactive Pay     
      0.00                0.00                0.00

<Press enter to continue>

What is your name? What is your current salary? What is your pay increase? 
's SALARY INFORMATION
New Salary          Monthly Salary      Retroactive Pay     
      0.00                0.00                0.00

<Press enter to continue>

What is your name? What is your current salary? What is your pay increase? 
's SALARY INFORMATION
New Salary          Monthly Salary      Retroactive Pay     
      0.00                0.00                0.00

<Press enter to continue>