Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //bkelly/nparmar array hw for cs-180
- #include<iostream>
- #include<iomanip>
- using namespace std;
- void compute(double annualsalary[], double percentincrease[], double raise[], double newannualsalary[], const int size); //prototyping
- void highestandlowest(double newannualsalary[], double & highest, double & lowest, const int size); //prototyping
- void search(int employeenumber[], int departmentnumber[], double annualsalary[], double doublepercentincrease[], double raise[], double doublenewannualsalary[], const int size); //prototyping
- int main() {
- system("cls");
- const int size = 6;
- int employeenumber[size] = { 1926, 2071, 3550, 44298, 5409, 6552 };
- int departmentnumber[size] = { 10, 14, 22, 35, 47, 31 };
- double annualsalary[size] = { 29000, 30250, 24175, 33400, 27500, 31773 };
- double percentincrease[size] = { .1, .12, .07, .11, .08, .10 };
- double raise[size] = { 0 }, newannualsalary[size] = { 0 };
- double highest = 0, lowest = 100000;
- compute(annualsalary, percentincrease, raise, newannualsalary, size);
- for (int x = 0; x < size; x++) {
- cout << employeenumber[x] << setw(13) << departmentnumber[x] << setw(13) << annualsalary[x] << setw(13) << percentincrease[x] << setw(13) << raise[x] << setw(13) << newannualsalary[x] << endl;
- }
- cout << endl << endl;
- highestandlowest(newannualsalary, highest, lowest, size);
- cout << "Highest new annual salary " << highest << endl;
- cout << "Lowest new annual salary " << lowest << endl;
- search(employeenumber, departmentnumber, annualsalary, percentincrease, raise, newannualsalary, size);
- return 0;
- }
- void compute(double annualsalary[], double percentincrease[], double raise[], double newannualsalary[], const int size) {
- for (int x = 0; x < size; x++) {
- raise[x] = annualsalary[x] * percentincrease[x];
- newannualsalary[x] = annualsalary[x] + raise[x];
- }
- }
- void highestandlowest(double newannualsalary[], double & highest, double & lowest, const int size) {
- for (int x = 0; x < size; x++) {
- if (newannualsalary[x] > highest) {
- highest = newannualsalary[x];
- }
- if (newannualsalary[x] < lowest) {
- lowest = newannualsalary[x];
- }
- }
- }
- void search(int employeenumber[], int departmentnumber[], double annualsalary[], double percentincrease[], double raise[], double newannualsalary[], const int size) {
- int empnum;
- bool found = false;
- cout << endl << endl << "Enter the employee number to find: ";
- cin >> empnum;
- for (int x = 0; x < size; x++) {
- if (empnum == employeenumber[x]) {
- cout << employeenumber[x] << setw(13) << departmentnumber[x] << setw(13) << annualsalary[x] << setw(13) << percentincrease[x] << setw(13) << raise[x] << setw(13) << newannualsalary[x] << endl;
- found = true;
- }
- }
- if (found == false) {
- cout << "Record not found. " << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement