Advertisement
okelikai

Array Project

Nov 15th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.87 KB | None | 0 0
  1. //bkelly/nparmar array hw for cs-180
  2. #include<iostream>
  3. #include<iomanip>
  4. using namespace std;
  5.  
  6. void compute(double annualsalary[], double percentincrease[], double raise[], double newannualsalary[], const int  size);                                                           //prototyping
  7. void highestandlowest(double newannualsalary[], double & highest, double & lowest, const int size);                                                                                 //prototyping
  8. void search(int employeenumber[], int departmentnumber[], double annualsalary[], double doublepercentincrease[], double raise[], double doublenewannualsalary[], const int size);   //prototyping
  9.  
  10.  
  11.  
  12.  
  13. int main() {
  14.  
  15.     system("cls");
  16.  
  17.     const int size = 6;
  18.     int employeenumber[size] = { 1926, 2071, 3550, 44298, 5409, 6552 };
  19.     int departmentnumber[size] = { 10, 14, 22, 35, 47, 31 };
  20.     double annualsalary[size] = { 29000, 30250, 24175, 33400, 27500, 31773 };
  21.     double percentincrease[size] = { .1, .12, .07, .11, .08, .10 };
  22.     double raise[size] = { 0 }, newannualsalary[size] = { 0 };
  23.     double highest = 0, lowest = 100000;
  24.  
  25.     compute(annualsalary, percentincrease, raise, newannualsalary, size);
  26.  
  27.     for (int x = 0; x < size; x++) {
  28.         cout << employeenumber[x] << setw(13) << departmentnumber[x] << setw(13) << annualsalary[x] << setw(13) << percentincrease[x] << setw(13) << raise[x] << setw(13) << newannualsalary[x] << endl;
  29.  
  30.     }
  31.  
  32.     cout << endl << endl;
  33.  
  34.     highestandlowest(newannualsalary, highest, lowest, size);
  35.  
  36.     cout << "Highest new annual salary " << highest << endl;
  37.     cout << "Lowest new annual salary " << lowest << endl;
  38.  
  39.     search(employeenumber, departmentnumber, annualsalary, percentincrease, raise, newannualsalary, size);
  40.  
  41.     return 0;
  42.  
  43. }
  44.  
  45.  
  46.  
  47. void compute(double annualsalary[], double percentincrease[], double raise[], double newannualsalary[], const int size) {
  48.    
  49.     for (int x = 0; x < size; x++) {
  50.         raise[x] = annualsalary[x] * percentincrease[x];
  51.         newannualsalary[x] = annualsalary[x] + raise[x];
  52.     }
  53.  
  54. }
  55.  
  56.  
  57.  
  58. void highestandlowest(double newannualsalary[], double & highest, double & lowest, const int size) {
  59.    
  60.     for (int x = 0; x < size; x++) {
  61.         if (newannualsalary[x] > highest) {
  62.             highest = newannualsalary[x];
  63.         }
  64.  
  65.         if (newannualsalary[x] < lowest) {
  66.             lowest = newannualsalary[x];
  67.         }
  68.  
  69.     }
  70.  
  71. }
  72.  
  73.  
  74.  
  75.  
  76.  
  77. void search(int employeenumber[], int departmentnumber[], double annualsalary[], double percentincrease[], double raise[], double newannualsalary[], const int size) {
  78.    
  79.     int empnum;
  80.     bool found = false;
  81.  
  82.     cout << endl << endl << "Enter the employee number to find: ";
  83.     cin  >> empnum;
  84.  
  85.     for (int x = 0; x < size; x++) {
  86.         if (empnum == employeenumber[x]) {
  87.  
  88.             cout << employeenumber[x] << setw(13) << departmentnumber[x] << setw(13) << annualsalary[x] << setw(13) << percentincrease[x] << setw(13) << raise[x] << setw(13) << newannualsalary[x] << endl;
  89.  
  90.             found = true;
  91.  
  92.         }
  93.  
  94.  
  95.  
  96.     }
  97.  
  98.     if (found == false) {
  99.         cout << "Record not found. " << endl;
  100.     }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement