Advertisement
Guest User

Test 3 Review

a guest
Oct 25th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<iostream>
  3. #include<iomanip>
  4. #include<string>
  5. using namespace std;
  6.  
  7. class PayRaise
  8. {
  9. public:
  10. PayRaise(char * = "", float = 0.0, float = 0.0);
  11. ~PayRaise();
  12. void printData();
  13. void calcBonus(float);
  14.  
  15. private:
  16. char name[20];
  17. float old, rp, ra, newp;
  18. };
  19.  
  20. PayRaise::PayRaise(char*n, float o, float r)
  21. {
  22. strcpy(name, n);
  23. old = o;
  24. rp = r;
  25. ra = (old*rp) / 100;
  26. newp = old + ra;
  27. }
  28.  
  29. PayRaise::~PayRaise()
  30. {
  31. cout << name << " is destroyed" << endl << endl;
  32. system("PAUSE");
  33. }
  34.  
  35. void PayRaise::printData()
  36. {
  37. cout << setprecision(2) << showpoint << fixed;
  38. cout << "The person's name is " << name << endl;
  39. cout << "The old pay amount is $ " << old << endl;
  40. cout << "The raise percentage is " << rp << endl;
  41. cout << "The raise amount is $ " << ra << endl;
  42. cout << "The new pay is $ " << newp << endl << endl << endl;
  43. }
  44.  
  45. void PayRaise::calcBonus(float bonus)
  46. {
  47. old += bonus;
  48. ra = (old*rp) / 100;
  49. newp = old + ra;
  50. }
  51.  
  52. int main()
  53. {
  54. PayRaise p("Corby Bryan", 50000, 10);
  55. p.printData();
  56. cout << endl << endl << "How much is the bonus? ";
  57. float bonus;
  58. cin >> bonus;
  59. p.calcBonus(bonus);
  60. cout << endl << endl << "After the bonus: " << endl << endl;
  61. p.printData();
  62. cout << endl << endl;
  63. return 0;
  64. }
  65. /*
  66. The person's name is Corby Bryan
  67. The old pay amount is $ 50000.00
  68. The raise percentage is 10.00
  69. The raise amount is $ 5000.00
  70. The new pay is $ 55000.00
  71.  
  72.  
  73.  
  74.  
  75. How much is the bonus? 10000
  76.  
  77.  
  78. After the bonus:
  79.  
  80. The person's name is Corby Bryan
  81. The old pay amount is $ 60000.00
  82. The raise percentage is 10.00
  83. The raise amount is $ 6000.00
  84. The new pay is $ 66000.00
  85.  
  86.  
  87.  
  88.  
  89. Corby Bryan is destroyed
  90.  
  91. Press any key to continue . . .
  92. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement