Question

In: Computer Science

Design and implement a C++ Application that: Interactively input: Employee First Name Employee Last Name Employee...

Design and implement a C++ Application that:

Interactively input:

  • Employee First Name
  • Employee Last Name
  • Employee id
  • Employee hours worked per week
  • Employee Pay Rate

Menu with Option to:

  • Print out Employee Report in the following report format
  • Search for an Employee
  • Display the Report in Sorted based on Last Name or ID
  • Calculate the Pay
  • Quit

Criteria:

  • Be sure to use Parallel Arrays to Store the Employee Information
  • Output must be formatted and line up with the column header
  • It must support interactive data input
  • output displays on the screen for different reports

Use this data for input:

  • Brian Adams 612366 36
  • David Eisenhower 957654 38
  • Kathy Jones 123456 43
  • Janet Williams 245695 39
  • Steve Bradford 245690 39

MARKETING COMPANY REPORT PROGRAM

FIRST NAME LAST NAME ID HOURS WORKED Hourly Rate Total Pay
Brian Adams 612366 36
David Eisenhower 957654 38
Kathy Jones 123456 43
Janet Williams 245695 39
Steve Bradford 245690 39

Average Hours Worked: 39 Hrs/Week

Solutions

Expert Solution


Program Screen Shot:

Sample Output:

Program Code to Copy:

#include<iostream>
#include <vector>
#include<iomanip> // for cout formatting: decimal places, width
using namespace std;

struct Employee{
string FirstName;
string LastName;
unsigned int Id;
int HoursWorked; // per week
double PayRate;
// function to display employee info.
void print(){
cout
<<setw(15)<<FirstName<<"\t"
<<setw(15)<<LastName<<"\t"
<<setw(15)<<Id<<"\t"
<<setw(15)<<HoursWorked<<"\t"
<<setw(15)<<setprecision(2)<<fixed<<PayRate<<"\t"
<<setw(15)<<setprecision(2)<<fixed<<HoursWorked*PayRate<<"\n";
}
};

// sort employees ascending by Id
void sortById(vector<Employee>&database){ // database passed by reference
struct Employee temporary;
for(int i = 0;i<database.size(); ++i){
for(int j = i + 1; j < database.size(); ++j){
if(database[i].Id > database[j].Id){
temporary = database[i];
database[i] = database[j];
database[j] = temporary;
}
}
}
}
int main(){
struct Employee employee; // to hold info for an employee
vector<Employee>database; // to store all employees
int choice = 0;
unsigned int search_id;
bool found;
char more_input;
char more_menu;

cout<<"\nMARKETING COMPANY REPORT PROGRAM\n";
do{
cout<<"\nEnter First Name: "; cin>>employee.FirstName;
cout<<"\nEnter Last Name: "; cin>>employee.LastName;
cout<<"\nEnter ID: "; cin>>employee.Id;
cout<<"\nEnter Hours Worked: "; cin>>employee.HoursWorked;
cout<<"\nEnter Pay Rate: "; cin>>employee.PayRate;
database.push_back(employee); // store this employee

cout<<"Add More? (Y/N): ";
cin>>more_input;
}while(more_input=='Y' || more_input=='y');

do{
cout<<endl<<"Menu: \n";
cout<<"1 - Print out Employee Report"<<endl;
cout<<"2 - Search for an Employee"<<endl;
cout<<"3 - Display the Report, Sorted based on ID"<<endl;
cout<<"4 - Calculate the Pay"<<endl;
cout<<"5 - Quit"<<endl;
cin>>choice;
switch(choice){
case 1:
cout
<<setw(15)<<"\nFIRST NAME\t"
<<setw(15)<<"LAST NAME\t"
<<setw(15)<<"ID\t"
<<setw(15)<<"HOURS WORKED\t"
<<setw(15)<<"HOURLY RATE\t"
<<setw(15)<<"TOTAL PAY\n";
for(Employee employee : database)
employee.print();
break;
case 2:
found = false;
cout<<"\nEnter employee id to search: ";
cin>>search_id;
for(Employee employee : database)
if(employee.Id == search_id){
employee.print(); // display this employ
found = true;
}
if (!found)
cout<<"Employee with id "<<search_id<<" is not found";
break;
case 3:
sortById(database);
cout
<<setw(15)<<"\nFIRST NAME\t"
<<setw(15)<<"LAST NAME\t"
<<setw(15)<<"ID\t"
<<setw(15)<<"HOURS WORKED\t"
<<setw(15)<<"HOURLY RATE\t"
<<setw(15)<<"TOTAL PAY\n";
for(Employee employee : database)
employee.print();
break;
case 4:
found = false;
cout<<"\nEnter employee id to calculate pay: ";
cin>>search_id;
for(Employee employee : database)
if(employee.Id == search_id){
cout<<"\nThe pay is "<<employee.HoursWorked*employee.PayRate<<endl; //total pay
found = true;
}
if (!found)
cout<<"\nError calculating pay. Employee with id "<<search_id<<" is not found\n";
break;
case 5:
cout<<"Good bye!";
exit(0);
break;
default: // do anything
break;
}
cout<<"\nGo back to main menu? (Y/N): ";
cin>>more_menu;
}while(more_menu=='Y'||more_menu=='y');
return 0;
}

------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,

IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~


Related Solutions

C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
C++ Change the program to take user input for first name and last name for five...
C++ Change the program to take user input for first name and last name for five employees. Add a loop to read the first name and last name. // EmployeeStatic.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include <iostream> #include <string> using namespace std; class Employee { public:    Employee(const std::string&, const std::string&); // constructor    ~Employee(); // destructor    std::string getFirstName() const; // return first name    std::string getLastName() const; // return...
C# (Thank you in advance) Create an Employee class with five fields: first name, last name,...
C# (Thank you in advance) Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and initSalary. It includes constructor(s) and properties to initialize values for all fields. Create an interface, SalaryCalculate, class that includes two functions: first,CalcYearWorked() function, it takes one parameter (currentyear) and calculates the number of year the worker has been working. The second function, CalcCurSalary() function that calculates the current year salary. Create a Worker classes that is derived from Employee and SalaryCalculate...
Design and implement a C++ program read in a whole line of characters as the input...
Design and implement a C++ program read in a whole line of characters as the input string; count and display how many times how frequently (among the letters) each (case insensitive) letter appears in the above mentioned input string; Sample program execution: An example of executing such a program is shown below. Note that the user input is in italic font. Please enter a line of characters: This is a really long line of characters! There are 41 characters in...
IN C++ PLEASE!!! Design and implement a program (name it Coins) that determines the values of...
IN C++ PLEASE!!! Design and implement a program (name it Coins) that determines the values of coins in a jar. The program prints out the total dollars and cents in the jar. The program prompts the user to enter the number of coins (quarters, dimes, nickels, and pennies). Print out the number of coins entered for each coin type on separate lines followed by the total amount of money in the jar as dollars and cents as shown below.
Problem 44 Write a query to display the employee number, last name, first name, and sum...
Problem 44 Write a query to display the employee number, last name, first name, and sum of invoice totals for all employees who completed an invoice. Sort the output by employee last name and then by first name (Partial results shown in Figure P7.44).
A, B:   Design and Implement a C# windows form application to ask the user for 10...
A, B:   Design and Implement a C# windows form application to ask the user for 10 integer numbers, sort them in ascending order and display the sorted list. Use bubble sort technique to sort the array elements and do not use any built-in sort method to sort the array elements.                                                        [02] C:    Test and evaluate your program by inputting variety of values.
A, B:    Design and Implement a C# windows form application to encrypt and decrypt text....
A, B:    Design and Implement a C# windows form application to encrypt and decrypt text. The application use to receive a string and display another encrypted string. The application also decrypt the encrypted string. The approach for encryption/decryption is simple one i.e. to encrypt we will add 1 to each character, so that "hello" would become "ifmmp", and to decrypt we would subtract 1 from each character.    C:   Test and evaluate application by applying different strings.      ...
IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Rectangle) to calculate and display...
IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Rectangle) to calculate and display the area and perimeter of a rectangle with width = 4 and height = 8.
PLEASE DO THIS IN C#Design and implement a programming (name it NextMeeting) to determine the day...
PLEASE DO THIS IN C#Design and implement a programming (name it NextMeeting) to determine the day of your next meeting from today. The program reads from the user an integer value representing today’s day (assume 0 for Sunday, 1 for Monday, 2 for Tuesday, 3 for Wednesday, etc…) and another integer value representing the number of days to the meeting day. The program determines and prints out the meeting day. Format the outputs following the sample runs below. Sample run...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT