Arrays

The program below gives a starting point. Each function can be added and tested individually.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Employee Program
#include<iostream>
#include <iomanip>
#include<string>
#include <fstream>
using namespace std;
void addEmployee(string name[], double rate[], char gender[],int &count); //add new employee
void genderRate(double rate[], char gender[],int count); //show average rate for men and women
char menu();  //shows choices, inputs and returns selection
void printAll(string name[], double rate[], char gender[],int count); //list all employees
void raiseRateAll(double rate[],int count); //Raise the rate of all employees by same amount
void raiseRateOne(string name[], double rate[], int count); //Raise rate for one employee
void processChoice(char choice, string lastname[], double rate[], char gender[],int count); //call selected function
void readfile(string name[], double rate[], char gender[],int count); //reads file and populates arrays
int search(string name, string lastname[], int count); //searches for one name, returns position or -1

int main() {
  string lastname[40]={"Brown","Smith","Jones"}; //allow 40 names 
  double rate[40]={7.50,9.00,8.25}; //hourly rate for same 40 people
  char gender[40]={'m','f','m'};
  int employCount=3; //number of people, there may be less than 20
  char choice=menu();
  while ((choice != 'q' ) && (choice != 'Q' ) ){
    choice=menu();
  } //while
  system("pause");
  return 0;
} //main

char menu()	{ //show menu and return selection 
  char choice;   
  cout<<"Enter Q to quit.\n";
  cin>>choice;
  return choice;
} //menu
CODE

NEXT: Templates