Advertisement
Guest User

Payroll - 0.x1

a guest
Dec 6th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. double hire(float date) { //Takes date from main() for int part of row[0] of column[i]
  7. double employees[3][4], pin, id;
  8. int input, hours;
  9. float payrate;
  10.  
  11. cout.precision(3);
  12.  
  13. bool flag = false;
  14.  
  15. while (!flag) { //Checks for proper employee
  16. cout << "Which employee's information would you like to alter? (1, 2, or 3): "; //Ask user for employee
  17. cin >> input;
  18. if (input == 1 || input == 2 || input == 3) {
  19. flag = true;
  20. }
  21. else {
  22. cout << "Sorry, but that's not an option. Please try again." << endl; //Restarts while() checker
  23. }
  24. }
  25. cout << "You are now editing employee " << input << "'s information." << endl << "An ID number is being assigned. Please wait..." << endl; //Assigns employee[i] an ID number
  26. Sleep(750);
  27.  
  28. double pinholder = (double)(rand() % 1000);
  29. pin = pinholder / 1000;
  30.  
  31. id = date + pin;
  32. cout << fixed << endl << "Employee " << input << " has been assigned as: " << id << endl; //Displays and fills employee hiredate and ID in row[1] of column[i] to user
  33. employees[input - 1][0] = id;
  34.  
  35. cout << "Please enter employee " << input << "'s hours, to the closest rounded whole number: "; //Fills column[i], row[1] with hours of employee
  36. cin >> hours;
  37. employees[input - 1][1] = hours;
  38.  
  39. cout << "Please enter employee " << input << "'s payrate: "; // Fills column[i], row[2] with the payrate of the employee as $$.$$
  40. cin >> payrate;
  41. employees[input - 1][2] = payrate;
  42.  
  43. cout.precision(2); //Changes decimal precision to 2 places, for cents in a dollar
  44.  
  45. cout << "The gross wages of employee " << input << " for this month were $" << hours * payrate << "."; //Displays and fills column[i], row[3] with gross wages of employee
  46. employees[input - 1][3] = (hours * payrate);
  47.  
  48. cout.precision(3); //Changes decimal precision back to 3 places
  49.  
  50.  
  51.  
  52. return 0;
  53. }
  54.  
  55. int main() {
  56. double date, day, month, year, i = 1;
  57.  
  58. cout << "Welcome! Please enter the current year: ";
  59. cin >> year;
  60. Sleep(500);
  61.  
  62. cout << "The current year is " << year << "." << endl << "Please enter the current month (numerically): ";
  63. cin >> month;
  64. Sleep(500);
  65.  
  66. cout << "The place of the current month is " << month << "." << endl << "Please enter the current day: ";
  67. cin >> day;
  68. Sleep(500);
  69.  
  70. cout << "It is currently the " << day << "th day of the " << month << "th month, in the year " << year << "." << endl << endl << endl;
  71. date = (month * 1000000) + (day * 10000) + year;
  72.  
  73. hire(date);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement