All pastes #427853 Raw Edit

Stuff

public cpp v1 · immutable
·published 2007-04-07 01:38 UTC
rendered paste body
//Jordan Steffen//stej4019//201-807//to provide employee adding//updating, and wage reporting//functionality#include <iostream>using namespace std;void menu(int &option);void add(int ids[], string names[], float wages[], int size, int &loc);void updateName(string names[], int ids[],  int size, int &loc);	void updateWage(float wages[], int ids[],  int size, int &loc);void displayPaycheck(float wages[], int ids[], int size, int &loc);bool search3(const int ids[], const int size, int key, int &loc);int main(){  int loc;  int option;  const int size = 100;  int ids[size] = -1;  string names[size];  float wages[size];  int choicesentinel = 1;  while(choicesentinel != 5){	  menu(option);	  if (option == 1)  {	  add(ids, names, wages);  }  if (option == 2)  {	  updateName(names, ids);  }  if (option == 3)  {	  updateWage(wages, ids);  }  if (option == 4)  {	  displayPaycheck(wages, ids);  }  if(option == 5)  {	  choicesentinel = 5;  }	  }    return 0;}void menu(int &option){  cout<<'\n'<<'\n'<<"---------------------------------"<<endl;  cout<<"| 1.) Add an Employee           |"<<endl;  cout<<"| 2.) Update an Employee Name   |"<<endl;  cout<<"| 3.) Update an Employee Wage   |"<<endl;  cout<<"| 4.) Display a Paycheck Report |"<<endl;  cout<<"| 5.) Quit                      |"<<endl;  cout<<"---------------------------------"<<endl;  cout<<"| Select an option ( 1 - 5 ) : ";  cin>>option;  cout<<"---------------------------------"<<endl;}void add(int ids[], string names[], float wages[], int size, int loc){		cout<<"Please enter new employee's unique ID number : ";	int idsTemp;	cin>>idsTemp;	if (search3(ids, size, idsTemp, loc)	{		cout<<"This ID number already exists, please try again."<<endl;	}	else	}		cout<<"Please enter new employee's name : ";		string namesTemp;		cin>>namesTemp;		cout<<"Please enter new employee's wage : ";		float wagesTemp;		cin>>wagesTemp;	}}void updateName(string names[], int ids[],  int size, int &loc)	{	cout<<"Enter employee's ID #";	int idsTemp;	cin>>idsTemp;	if (search3(ids, size, idsTemp, loc)	{		cout<<"Employee's old name = "<<names[i]<<endl;		cout<<"Enter employee's new name : ";		string namesTemp;		cin>>namesTemp;	}	else	{		cout<<"This employee ID does not exist, please try again."<<endl;	}}void updateWage(float wages[], int ids[],  int size, int &loc){	cout<<"Enter employee's ID #";	int idsTemp;	cin>>idsTemp;	if search3(ids, size, idsTemp, loc)	{		cout<<"Employee's old wage = "<<wages[i]<<endl;		cout<<"Enter employee's new wage : ";		float wagesTemp;		cin>>wagesTemp;	}	else	{		cout<<"This employee ID does not exist, please try again."<<endl;	}}	void displayPaycheck(float wages[], int ids[], int size, int &loc){	cout<<"Enter employee's id #";	int idsTemp;	cin>>idsTemp;	if search3(ids, size, idsTemp, loc)	{		cout<<"Enter employee's total hours : ";		int hours;		cin>>hours;		if(hours > 40)		{			float pay;			pay =  40 * wages[i]			cout<<'\n'<<"*******PayCheck Report*********"<<endl;			cout<<'\n'<<"Regular"<<endl;			cout<<"-------"<<endl;			cout<<"Wage = "<<wages[i]<<", Hours = 40";			cout<<", Pay = $"<<pay<<endl;			cout<<'\n'<<"Overtime"<<endl;			cout<<"-------"<<endl;			float otWage = wages[i] * 1.5;			cout<<"Wage = "<<otWage<<", Hours = "<<hours - 40;			float otPay = otWage * (hours - 40);			cout<<", Pay = $"<<otPay<<endl;			cout<<'\n'<<"Total"<<endl;			cout<<"-----"<<endl;			cout<<"Hours = "<<hours<<", Pay = $"<<pay + otPay<<endl;			cout<<'\n'<<"*******PayCheck Report*********"<<endl;					}			else		{			float pay;			pay =  hours * wages[i]			cout<<'\n'<<"*******PayCheck Report*********"<<endl;			cout<<'\n'<<"Total"<<endl;			cout<<"-------"<<endl;			cout<<"Wage = "<<wages[i]<<", Hours = "<<hours;			cout<<", Pay = $"<<pay<<endl;			cout<<'\n'<<"*******PayCheck Report*********"<<endl;			}	}bool search3(const int ids[], const int size, int key, int &loc){	for(loc = 0; loc < size  && ids[loc] != -1; ++loc)	{		if(ids[loc] == key)		{			return true;		}	}	return false;}