Guest User

Untitled

a guest
May 23rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. string getString()
  7. {
  8.     string str = "";
  9.     char c;
  10.     while ((c = cin.peek()) != 10 && c != '\n') { str += cin.get(); }
  11.     return str;
  12. }
  13.  
  14. void clear()
  15. {
  16.     char c;
  17.     while ((c = cin.peek()) != 10)  { cin.get(); }
  18. }
  19.  
  20. void clearAndWait()
  21. {
  22.     char c;
  23.     while ((c = cin.peek()) != 10)  { cin.get(); }
  24.     cin.ignore(2);
  25. }
  26.  
  27. int main()
  28. {
  29.     string name;
  30.     double gross=-1, fed, state, medi, health, net;
  31.  
  32.     cout << "Enter employee's name: ";
  33.     name=getString();
  34.     cout << "Enter gross income: ";
  35.     cin >> gross;
  36.  
  37.     if (gross<0)
  38.     {
  39.     cout << "Error use positve numbers only";
  40.     cout << "\nPress any key to exit";
  41.     clearAndWait();
  42.     return 0;
  43.     }
  44.  
  45.     fed=gross*.15;
  46.     state=gross*.035;
  47.     medi=gross*.085;
  48.     health=75;
  49.     net=gross-fed-state-medi-health;
  50.  
  51.     system("cls");
  52.     cout << name;
  53.     cout << fixed << setprecision(2);
  54.     cout << "\nGross Amount: $" << gross;
  55.     cout << "\nFederal Tax: $" << fed;
  56.     cout << "\nState Tax: $" << state;
  57.     cout << "\nSocial Sec / Medicare: $" << medi;
  58.     cout << "\nHealth Insurance: $" << health;
  59.     cout << "\nNet Pay: $" << net;
  60.  
  61.     clearAndWait();
  62.  
  63.   return 0;
  64. }
Add Comment
Please, Sign In to add comment