Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include using namespace std; struct employee_rec { string employeeid; string lastname; string firstname; float hours; float payrate; float taxrate; }; int main()

#include

#include

#include

#include

using namespace std;

struct employee_rec

{

string employeeid;

string lastname;

string firstname;

float hours;

float payrate;

float taxrate;

};

int main()

{

int const max = 100;

float grosspay, taxes, netpay;

bool again = true;

int option, numberemployees = 0;

employee_rec employee[15] = {"GH711", "Allan", "Barry", 36.7, 80.3, 0.31,

"JJ100", "Bunnie", "Bugs", 42.1, 28.4, 0.055,

"KL221", "Ducke", "Howard", 29.3, 14.5, 0.011,

"AS321", "DeMann", "Stan", 34.5, 28.95, 0.16,

"FG101", "Doome", "Victor", 49.5, 78.25, 0.02,

"NG201", "Ivy", "Samantha", 47.5, 70.91, 0.05,

"KH111", "Kent", "Clark", 40, 33.5, 0.01,

"HH107", "Neumann", "Alfred", 38.4, 30.94, 0.027,

"GW101", "Rodgers", "Steve", 47.8, 59.33, 0.031,

"BB002", "Skywalker", "Lucas", 45.7, 28.4, 0.11,

"GH121", "Smith", "Alias", 33.4, 33.5, 0.1,

"JJ287", "Williams", "B.H.", 33.1, 48.3, 0.023,

"JK202", "Xavier", "Charles", 39.4, 23.4, 0.04,

"AA100", "Smith", "M.R.", 33.4, 22.44, 0.075,

"VV111", "Prince", "Diana", 38.21, 55.61, 0.1};

numberemployees = sizeof(employee) / sizeof(employee[0]);

employee_rec record[max];

employee_rec *pToArray = &employee[0];

cout.precision(2);

cout.setf (ios::fixed | ios::showpoint);

while (again)

{

system("cls");

cout << " 1 - Display All Employees"

<< " 2 - Find One Particular Employee"

<< " 3 - Add a New Employee"

<< " 4 - Quit"

<< " Enter an Option(1-4): ";

cin >> option;

option = abs(option);

switch (option)

{

case 1:

{

pToArray = &employee[0];

system("cls");

cout << numberemployees << " Total Employees: ";

for (int n1 = 0; n1 < numberemployees; n1++)

{

grosspay = employee[n1].hours * employee[n1].payrate;

taxes = grosspay * employee[n1].taxrate;

netpay = grosspay - taxes;

cout << " Employee#" << (n1 + 1) << "\tEmployee ID " << (*pToArray).employeeid

<< " " << (*pToArray).lastname << ", " << (*pToArray).firstname

<< " Hours Worked: " << (*pToArray).hours

<< " Employee Pay Rate: " << "$" << (*pToArray).payrate

<< " Employee Tax Rate: " << (*pToArray).taxrate *100 << "%"

<< " Gross Pay\t" << "$" << grosspay

<< " Less Taxes\t" << "$" << taxes

<< " Net Pay\t\t" << "$" << netpay

<< " ";

*pToArray++;

}

cout << " Hit Any Key to continute...";

getch();

break;

}

case 2:

{

system("cls");

int index = 0;

cout << "Find an Employee by its Index in the Array: "

<< "Find an Employee By Its Index(0 to 14): ";

cin >> index;

switch (index)

{

case 0: case 1: case 2: case 3: case 4: case 5: case 6:

case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14:

grosspay = employee[index].hours * employee[index].payrate;

taxes = grosspay * employee[index].taxrate;

netpay = grosspay - taxes;

cout << " Index Location " << index << " of " << numberemployees - 1

<< " Employee ID: " << employee[index].employeeid

<< " " << employee[index].lastname << ", " << employee[index].firstname

<< " Hours Worked: " << employee[index].hours << " @$ " << employee[index].payrate

<< " Employee Tax Rate" << " @ " << employee[index].taxrate *100 << "%"

<< " Gross Pay\t" << "$" << grosspay

<< " Less Taxes\t" << "$" << taxes

<< " Net Pay\t\t" << "$" << netpay

<< " ";

}

cout << " Hit Any Key to continute...";

getch();

break;

}

case 3:

{

system("cls");

cin.ignore(200, ' ');

cout << "Add a new Employee:";

cout << " Record# " << numberemployees + 1 << " of " << max;

cout << " 1 of 6 - Enter Employee's ID: ";

getline(cin, employee[numberemployees+1].employeeid);

cout << " 2 of 6 - Enter Employee's Last Name: ";

getline(cin, employee[numberemployees+1].lastname);

cout << " 3 of 6 - Enter Employee's First Name: ";

getline(cin, employee[numberemployees+1].firstname);

cout << " 4 of 6 - Enter Employee's Hours: ";

cin >> employee[numberemployees+1].hours;

cout << " 5 of 6 - Enter Employee's Payrate: ";

cin >> employee[numberemployees+1].payrate;

cout << " 6 of 6 - Enter Employee's Taxrate: ";

cin >> employee[numberemployees+1].taxrate;

break;

}

case 4:

{

system("cls");

cout << "Hit Any Key to Quit...";

getch();

exit(0);

break;

}

default:

{

system("cls");

cout << " You entered \"" << option << "\" which is not vaild! "

<< "Hit Any Key to continue...";

getch();

}

}

}

system("cls");

}

-----------------------------------------------------------------------------------------------------------------

I cannot run option3, which I certainly believe my code of case 3 has some problems. Can you find it out?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago