Advertisement
JustACodingStudent

Payrolls R' Us (School Project)

Mar 7th, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     string name, ss;
  8.     int bsal, location, customers;
  9.     double ttlsales, comrate, gpay, com;
  10.     char response;
  11.     customers = 0;
  12.     cout << "Enter SS Number: ";
  13.     cin >> ss;
  14.     cout << "Enter full name: ";
  15.     cin.ignore();
  16.     getline(cin, name);
  17.     cout << "Enter base salary: ";
  18.     cin >> bsal;
  19.     cout << "Enter total sales: ";
  20.     cin >> ttlsales;
  21.  
  22.     //Checks to see what the user's base salary is in order to create a commision rate.
  23.  
  24.     switch(bsal){
  25.         case 5000:
  26.             comrate = .05;
  27.             break;
  28.         case 3500:
  29.             comrate = .08;
  30.             break;
  31.         case 2000:
  32.             comrate = .1;
  33.             break;
  34.         default:
  35.             comrate = .04;
  36.             break;
  37.     }
  38.     com = ttlsales * comrate;
  39.     gpay = bsal + com;
  40.     system("cls");
  41.     cout << "Gross Pay Summary for: " << name.substr(0, 1) << ".";
  42.     location = name.find(" ");
  43.     cout << name.substr(location, name.length() - location) << ", XXX-XX-" << ss.substr(5, 9) << "\n" << endl;
  44.     cout << "Base Salary: $" << bsal << ".00"<< endl;
  45.     cout << "Total Sales: $" << ttlsales << ".00" << endl;
  46.     cout << "Gross Pay: $" << gpay << ".00\n" << endl;
  47.     customers = customers ++;
  48.     cout << "Would you like to compute another user?(y/n)" << endl;
  49.     cin >> response;
  50.  
  51.     //Loops the program until the user answers no.
  52.  
  53.     do{
  54.         system("cls");
  55.             cout << "Enter SS Number: ";
  56.     cin >> ss;
  57.     cout << "Enter full name: ";
  58.     cin.ignore();
  59.     getline(cin, name);
  60.     cout << "Enter base salary: ";
  61.     cin >> bsal;
  62.     cout << "Enter total sales: ";
  63.     cin >> ttlsales;
  64.  
  65.     switch(bsal){
  66.         case 5000:
  67.             comrate = .05;
  68.             break;
  69.         case 3500:
  70.             comrate = .08;
  71.             break;
  72.         case 2000:
  73.             comrate = .1;
  74.             break;
  75.         default:
  76.             comrate = .04;
  77.             break;
  78.     }
  79.     com = ttlsales * comrate;
  80.     gpay = bsal + com;
  81.     system("cls");
  82.     cout << "Gross Pay Summary for: " << name.substr(0, 1) << ".";
  83.     location = name.find(" ");
  84.     cout << name.substr(location, name.length() - location) << ", XXX-XX-" << ss.substr(5, 9) << "\n" << endl;
  85.     cout << "Base Salary: $" << bsal << ".00"<< endl;
  86.     cout << "Total Sales: $" << ttlsales << ".00" << endl;
  87.     cout << "Gross Pay: $" << gpay << ".00\n" << endl;
  88.     customers = customers ++;
  89.     cout << "Would you like to compute another user?(y/n)" << endl;
  90.     cin >> response;
  91.     }while(response == 'y');
  92.  
  93.     cout << "\nYou have processed " << customers <<  " customers today." << endl;
  94.     cout << "Thank you for using Payrolls R' Us! Have a good day!" << endl;
  95.     int x;
  96.     cin>>x;
  97.     return(0);
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement