Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<iostream>
- #include<iomanip>
- #include<string>
- using namespace std;
- class PayRaise
- {
- public:
- PayRaise(char * = "", float = 0.0, float = 0.0);
- ~PayRaise();
- void printData();
- void calcBonus(float);
- private:
- char name[20];
- float old, rp, ra, newp;
- };
- PayRaise::PayRaise(char*n, float o, float r)
- {
- strcpy(name, n);
- old = o;
- rp = r;
- ra = (old*rp) / 100;
- newp = old + ra;
- }
- PayRaise::~PayRaise()
- {
- cout << name << " is destroyed" << endl << endl;
- system("PAUSE");
- }
- void PayRaise::printData()
- {
- cout << setprecision(2) << showpoint << fixed;
- cout << "The person's name is " << name << endl;
- cout << "The old pay amount is $ " << old << endl;
- cout << "The raise percentage is " << rp << endl;
- cout << "The raise amount is $ " << ra << endl;
- cout << "The new pay is $ " << newp << endl << endl << endl;
- }
- void PayRaise::calcBonus(float bonus)
- {
- old += bonus;
- ra = (old*rp) / 100;
- newp = old + ra;
- }
- int main()
- {
- PayRaise p("Corby Bryan", 50000, 10);
- p.printData();
- cout << endl << endl << "How much is the bonus? ";
- float bonus;
- cin >> bonus;
- p.calcBonus(bonus);
- cout << endl << endl << "After the bonus: " << endl << endl;
- p.printData();
- cout << endl << endl;
- return 0;
- }
- /*
- The person's name is Corby Bryan
- The old pay amount is $ 50000.00
- The raise percentage is 10.00
- The raise amount is $ 5000.00
- The new pay is $ 55000.00
- How much is the bonus? 10000
- After the bonus:
- The person's name is Corby Bryan
- The old pay amount is $ 60000.00
- The raise percentage is 10.00
- The raise amount is $ 6000.00
- The new pay is $ 66000.00
- Corby Bryan is destroyed
- Press any key to continue . . .
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement