Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- string getString()
- {
- string str = "";
- char c;
- while ((c = cin.peek()) != 10 && c != '\n') { str += cin.get(); }
- return str;
- }
- void clear()
- {
- char c;
- while ((c = cin.peek()) != 10) { cin.get(); }
- }
- void clearAndWait()
- {
- char c;
- while ((c = cin.peek()) != 10) { cin.get(); }
- cin.ignore(2);
- }
- int main()
- {
- string name;
- double gross=-1, fed, state, medi, health, net;
- cout << "Enter employee's name: ";
- name=getString();
- cout << "Enter gross income: ";
- cin >> gross;
- if (gross<0)
- {
- cout << "Error use positve numbers only";
- cout << "\nPress any key to exit";
- clearAndWait();
- return 0;
- }
- fed=gross*.15;
- state=gross*.035;
- medi=gross*.085;
- health=75;
- net=gross-fed-state-medi-health;
- system("cls");
- cout << name;
- cout << fixed << setprecision(2);
- cout << "\nGross Amount: $" << gross;
- cout << "\nFederal Tax: $" << fed;
- cout << "\nState Tax: $" << state;
- cout << "\nSocial Sec / Medicare: $" << medi;
- cout << "\nHealth Insurance: $" << health;
- cout << "\nNet Pay: $" << net;
- clearAndWait();
- return 0;
- }
Add Comment
Please, Sign In to add comment