Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string name, ss;
- int bsal, location, customers;
- double ttlsales, comrate, gpay, com;
- char response;
- customers = 0;
- cout << "Enter SS Number: ";
- cin >> ss;
- cout << "Enter full name: ";
- cin.ignore();
- getline(cin, name);
- cout << "Enter base salary: ";
- cin >> bsal;
- cout << "Enter total sales: ";
- cin >> ttlsales;
- //Checks to see what the user's base salary is in order to create a commision rate.
- switch(bsal){
- case 5000:
- comrate = .05;
- break;
- case 3500:
- comrate = .08;
- break;
- case 2000:
- comrate = .1;
- break;
- default:
- comrate = .04;
- break;
- }
- com = ttlsales * comrate;
- gpay = bsal + com;
- system("cls");
- cout << "Gross Pay Summary for: " << name.substr(0, 1) << ".";
- location = name.find(" ");
- cout << name.substr(location, name.length() - location) << ", XXX-XX-" << ss.substr(5, 9) << "\n" << endl;
- cout << "Base Salary: $" << bsal << ".00"<< endl;
- cout << "Total Sales: $" << ttlsales << ".00" << endl;
- cout << "Gross Pay: $" << gpay << ".00\n" << endl;
- customers = customers ++;
- cout << "Would you like to compute another user?(y/n)" << endl;
- cin >> response;
- //Loops the program until the user answers no.
- do{
- system("cls");
- cout << "Enter SS Number: ";
- cin >> ss;
- cout << "Enter full name: ";
- cin.ignore();
- getline(cin, name);
- cout << "Enter base salary: ";
- cin >> bsal;
- cout << "Enter total sales: ";
- cin >> ttlsales;
- switch(bsal){
- case 5000:
- comrate = .05;
- break;
- case 3500:
- comrate = .08;
- break;
- case 2000:
- comrate = .1;
- break;
- default:
- comrate = .04;
- break;
- }
- com = ttlsales * comrate;
- gpay = bsal + com;
- system("cls");
- cout << "Gross Pay Summary for: " << name.substr(0, 1) << ".";
- location = name.find(" ");
- cout << name.substr(location, name.length() - location) << ", XXX-XX-" << ss.substr(5, 9) << "\n" << endl;
- cout << "Base Salary: $" << bsal << ".00"<< endl;
- cout << "Total Sales: $" << ttlsales << ".00" << endl;
- cout << "Gross Pay: $" << gpay << ".00\n" << endl;
- customers = customers ++;
- cout << "Would you like to compute another user?(y/n)" << endl;
- cin >> response;
- }while(response == 'y');
- cout << "\nYou have processed " << customers << " customers today." << endl;
- cout << "Thank you for using Payrolls R' Us! Have a good day!" << endl;
- int x;
- cin>>x;
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement