This assignment involves creating a program to track employee information. Keep the following information on an employee:
1. Employee ID (string, digits only, 6 characters)
2. Last name (string)
3. First Name (string)
4. Birth date (string as MM/DD/YYYY)
5. Gender (M or F, single character)
6. Start date (string as MM/DD/YYYY)
7. Salary per year (double)
Thus you must create a class that has all of this, and get/set methods for each of these fields. Note: The fields that are designated as string should use the string class, not a char array.
Your class must have two constructors:
1. No arguments. Just construct an object, setting fields to empty (strings) or 0 (numbers). This one is not used, but write it anyway.
2. Takes all information.
When the program starts it must check to see if a file called Employee.txt exists. If not, create it as an empty file. If it does, read the information into Employee objects which you dynamically allocate and put them into an array of pointers to objects. Data in the file is stored separated by spaces, one employee per line. Assume the company will have no more than 100 employees, but if it does, show an error. You may not use vectors.
The program will have a menu that shows the following options:
1. Enter new employee information. When the ID is entered, make sure that ID is not in use for another employee. Request the rest of the info and create a new Employee object. While some input validation would be good, the only requirement is that the data not be null and that the salary must be a valid floating-point number greater than zero. (Doing proper input validation is beyond the scope of this exercise and could easily double the size of the program. Dates, in particular, are difficult to validate.)
2. Display all employee information in alphabetical order by last name. The list may not have been entered in order, but you must sort it to display it. Show all of the information in fixed-field columns so that it looks neat. (You can use printf for this if you like.) Show the salary to the nearest dollar, right-justified. The last column must be the monthly pay, a derived attribute.
3. Look up an employee by ID. If the ID exists, show all of the information, neatly formatted as in step 2. If not, display a message.
4. Remove an employee. Ask for an employee ID, and if the ID exists, delete. If not, display a message that there is no such employee. This should delete the object pointer from your array and remove the Employee object from memory. (How do you handle this in the array?)
5. Save all data to Employee.txt and exit. If the file exists, overwrite it. If it does not exist, create it.
Invalid menu options will display a message and return to show the menu. After executing options 1 through 4, return to the menu. Option 5 saves and exits.
The Employee class will not have a method to write all of the employees to the file, since it does not know about more than one employee at a time. However, you will have a method somewhere in your program to write them all out, with each piece of data separated by a blank, with one employee per line. The best place to put this is in a separate class that has two methods: read all employees and write all employees. This is consistent with three-layer architecture and good design principles.
To hand in: Five files, called Employee.h, Employee.cpp, FileIO.h, FileIO.cpp, and <netID>Asg5.cpp. Place these into a Zip file called <netID>Asg5.zip and hand that in.
Grading | |
Program initializes properly, reading information if it is there | 10 |
Each menu item 1 through 5 works correctly. 15 points each | 75 |
Employee class contains all and only the necessary functions and follows conventions for how classes work | 5 |
Program comments and good variable names | 10 |
Additional grading guidelines:
1. Method in Employee class that does I/O, including display: -5
2. Function in your main program that does file I/O. -10
3. Not using pointers to objects. -10
4. Use of Vectors: -10
5. Not closing files that have been opened: -5
6. Not freeing allocated memory when deleting an employee: -5
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Please help with this C++ code. If possible comment the code and please send screenshots of the code. This assignment involves creating a program to track employee information. Keep the following information on an employee: Employee ID (string) Last name (string) First Name (string) Birth date (string as MM/DD/YYYY) Gender (M or F, single character) Start date (string as MM/DD/YYYY) Salary per year (double) Thus you must create a class that has all of this, and get/set methods for each...
Part 1 (employee.py): Write a class name Employee that holds the following data about an employee in attributes:name, ID number, department and job title. Once you have written the class, write a program that creates three Employee objects to hold the following data: The program should store this data in the three objects, then display the data for each employee on the screen as a table like this (Use fstring or "format" function to format the output as a table,...
In header file (.h) and c++ file format (.cpp). A local company has asked you to write a program which creates an Employee class, a vector of Employee class objects, and fills the objects with employee data, creating a "database" of employee information. The program allows the user to repeatedly search for an employee in the vector by entering the employee's ID number and if found, display the employee's data. The Employee_C class should have the following data and in...
In Java: Executable Class create an array of Employee objects. You can copy the array you made for Chapter 20. create an ArrayList of Employee objects from that array. use an enhanced for loop to print all employees as shown in the sample output. create a TreeMap that uses Strings for keys and Employees as values. this TreeMap should map Employee ID numbers to their associated Employees. process the ArrayList to add elements to this map. print all employees in...
public class EmployeeDriver public static void main(String[] args) 1/declare create an Employee object named joo. Une no-arg constructor 1/change the attributes for joe as the following: //name to Joe Cool, id to 1111111, hours to 20, pay rate to 15 //dealare & create another Employee oblegt named one using arg-constructor // The name of the new employees Jane Doeid is 2001122. She makes $10.50/hour // change the object Jane's hours to 40. 1/change the object jane's pay rate to $12.00....
Within c++ Create a simple Employee class with name, department, and title. Create an hourlyEmployee class (which inherits from the Employee class) for a basic payroll program to compute the net pay salary of hourly based employees. Your program should also find the average net pay for a small company. To define the class, include the appropriate data members, member functions, constructors, and access modifiers. For simplicity, use a constant tax rate of 30% to compute the tax amount. Employees...
c++ only Design a class representing an Employee. The employee would have at least these private fields (Variables): name: string (char array) ID: string (char array) salary: float Type: string (char array) All the variables except for the salary should have their respective setters and getters, and the class should have two constructors, one is the default constructor and the other constructor initializes the name,ID and type of employee with valid user input. The class should have the following additional...
PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program to hold information about the gemstones he has in his safe. Offer the jewelry designer the following menu that loops until he chooses option 4. 1. Input a gemstone 2. Search for a gemstone by ID number 3. Display all gemstone information with total value 4. Exit ------------------------------------- Gemstone data: ID number (int > 0, must be unique) Gem Name (string, length < 15)...
Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...