Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

So for this problem, I want to make a txt data file to record the employee data and read it into the funtion and display

image text in transcribedimage text in transcribed

So for this problem, I want to make a txt data file to record the employee data and read it into the funtion and display in the end.

Below is my function, how can I change it?

#include #include using namespace std;

class employee { private: string name; int ID_number; string department; string position; public: employee (string newname, int newid, string newdepartment, string newposition); employee(string newname, int newid); employee(); void setupname(string); void setupid(int); void setupdepartment(string); void setupposition(string); string getname()const; int getid()const; string getdepartment()const; string getposition()const;

};

string arrey[3][4]; ifstream inFile;

employee::employee() { name = " "; ID_number = 0; department = ""; position = ""; } void employee::setupname(string newname) { name = newname; } void employee::setupid(int newid) { ID_number = newid; } void employee::setupdepartment(string newdepartment) { department = newdepartment; } void employee::setupposition(string newposition) { position = newposition; } string employee::getname()const { return name; } int employee::getid()const { return ID_number; } string employee::getdepartment()const { return department; } string employee::getposition()const { return position; }

#include #include #include "employee.h"

using namespace std;

int main() { employee sm; sm.setupname("Susan Meyers"); sm.setupid(47899); sm.setupdepartment("Accounting"); sm.setupposition("Vice President"); employee MJ; MJ.setupname("Mark Jones"); MJ.setupid(39119); MJ.setupdepartment("IT"); MJ.setupposition("Programmer"); employee JR; JR.setupname("Joy Rogers"); JR.setupid(81774); JR.setupdepartment("Manufacturing"); JR.setupposition("Engineer"); cout 2. Employee Class Write a class named Employee that has the following member variables: namea string that holds the employee's name idNumber-an int variable that holds the employee's ID number department-a string that holds the name of the department where the employee works positiona string that holds the employee's job title The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name, employee's ID number, depart- ment, and position. A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name and ID number. The department and position fields should be assigned an empty string(""). A default constructor that assigns empty strings ("") to the name, department, and position member variables, and 0 to the idNumber member variable. Write appropriate mutator functions that store values in these member variables and accessor functions that return the values in these member variables. Once you have written the class, write a separate program that creates three Employee objects to hold the following data: Name Susan Meyers Mark Jones Joy Rogers ID Number 47899 39119 81774 Department Accounting IT Manufacturing Position Vice President Programmer Engineer The program should store this data in the three objects and then display the data for each employee on the screen. In this problem, separate class specifications with implementation. Include default constructor only. User input is not required, instead read data from a file given in text book and create objects. Rest of the instructions are same

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions