fork download
  1. /*********************************************
  2.  * AUTHOR : Cecilia Rangel
  3.  * PROJECT #1 : BASIC INPUT/OUTPUT
  4.  * CLASS : CSC5
  5.  * SECTION : MW - 2:20 - 5:30pm
  6.  * DUE DATE : 9/21/26
  7.  **********************************************/
  8.  
  9. #include <iostream>
  10. #include <iomanip>
  11. #include <string>
  12. #include <vector>
  13. using namespace std;
  14.  
  15. /***********************************************************************
  16.  *
  17.  * COMPUTE RETROACTIVE PAY
  18.  * _____________________________________________________________________
  19.  * this program accepts as user input, as in employee
  20.  * name, current salary and percent increase and computes
  21.  * a new annual salary, new monthly salary and retroactive pay
  22.  * due. the program will loop three times, prompting the user for the
  23.  * Appropriate input and displaying the computed values for the given input.
  24.  *
  25.  * computations are based on the assumption that the input values are effective
  26.  * on January 1 and calculations are affective July 1
  27.  * _____________________________________________________________________
  28.  *INPUT
  29.  * nameFull : Employee's full name
  30.  * salleryCurrent : Current annual salary
  31.  * percent : Percent increase due
  32.  *
  33.  *OUTPUT
  34.  * salaryNew : New salary after applying increase
  35.  * salaryMonthly : new monthly salary
  36.  * retroactivePay : retroactive pay due
  37.  *
  38.  ***********************************************************************/
  39. int main ()
  40. {
  41. const int MONTHS = 12;
  42. const int RETRO_MONTHS = 6;
  43.  
  44. std:: string name;
  45. float salaryCurrent;
  46. float percentIncrease;
  47. float salaryNew;
  48. float salaryMonthly;
  49. float retroactivePay;
  50. cout << fixed;
  51.  
  52. for (int count =1; count <= 3; count++) {
  53. cin >> salaryCurrent;
  54. cin >> percentIncrease;
  55. cin.ignore();
  56. getline(cin, name);
  57. salaryNew = (1 + percentIncrease) * salaryCurrent;
  58. salaryMonthly = salaryNew / MONTHS;
  59. retroactivePay = (salaryMonthly - (salaryCurrent / MONTHS)) * RETRO_MONTHS;
  60.  
  61.  
  62. cout << "\n Employee name: " << showpoint << name;
  63. cout << "\n New salary: $" << setprecision(2) << showpoint << salaryNew;
  64. cout << "\n Monthly salary: $" << setprecision(2) << showpoint << salaryMonthly;
  65. cout << "\n Retroactive Pay: $" << showpoint << retroactivePay;
  66. }
  67. return 0;
  68. }
Success #stdin #stdout 0.01s 5320KB
stdin
80000 .05
Jean Cyr
5000 .07
abe Lincon
12512 .25
joe Jackson
stdout
 Employee name: Jean Cyr
 New salary: $84000.00
 Monthly salary: $7000.00
 Retroactive Pay: $2000.00
 Employee name: abe Lincon
 New salary: $5350.00
 Monthly salary: $445.83
 Retroactive Pay: $175.00
 Employee name: joe Jackson
 New salary: $15640.00
 Monthly salary: $1303.33
 Retroactive Pay: $1564.00