u are required to perform the following tasks: Create an Employee class with the following data members: char * name
u are required to perform the following tasks: Create an Employee class with the following data members: char * name
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 1CP: In previous chapters, you have created programs for the Greenville Idol competition. Now create a...
Related questions
Question
QUESTION 1
-
Write a C++ program that keeps taking input from the user about an Employee and stores them in the heap and then displays it. You are required to perform the following tasks:
- Create an Employee class with the following data members:
- char * name
- int age
- Make sure to have all the appropriate getters and setters along with a void toString() method that can display all the employee information in the form shown in the expected output screenshot.
- At the start of the program, it should ask user to enter Employee Name and Age. When user is done entering the information, the program should ask whether user wants to enter more employee information or not? If user presses ‘y’ or ‘Y’, the program should ask user to enter Employee Name and age for another employee, otherwise it should quit while displaying the report.
- Make sure to store the employee information in an array of employee and store it inside the heap memory on each employee entry from the user. You should start with the heap memory size of 0 and on each entry of employee name and age, an increment of heap memory size should happen so that on-demand heap memory is created for every new employee.
- Your program should have a resize function Employee* resize(Employee* arr, int* size) to resize the employee array in the heap on every entry of employee information from the user.
- Your program should have a display function void display(Employee* arr, int size) to display all the information by calling toString() method of employee class for all the objects in the employee array.
- Make sure to validate the input for age. For example, if user enters an invalid age (e.g., < 0), then user program should default age to 0 and inform user that age is set to 0 because of invalid entry.
- In display method in point (e), you should also be able to display, how many entries were corrected by the program due to invalid entries from the user. Please see highlighted parts of the output screenshot below for more information.
- Follow the modular
programming approach to organize your code and dont forget to indent and comment your code. - Below is the screenshot of the expected output of the program:
- Create an Employee class with the following data members:
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage