- #1
idle_09
- 6
- 0
Hi! Thanks for helping me. I need to write a program (in C++) that reads the file Employee.dat as input and then outputs to 4 different files which are Managers.dat, Marketing.dat, Developers.dat, and Testers.dat. Each of the output files contains the name of the employees of its category.
The fle Employee.dat contains following data:
Sue Leon 4
Robert Wise 3
Sam Woo 1
Nathan White 3
Suzan Head 2
Henry Williams 4
Christine Mint 1
Kim Leeds 4
Elton Sue 3
Ken Latch 2
Mentor note: The number associated with each employee is apparently his or her department. The enumeration in the code shows this.
I tried to write the program but I don't know what to put in "SWITCH" loop. Here is what i have so far.
The fle Employee.dat contains following data:
Sue Leon 4
Robert Wise 3
Sam Woo 1
Nathan White 3
Suzan Head 2
Henry Williams 4
Christine Mint 1
Kim Leeds 4
Elton Sue 3
Ken Latch 2
Mentor note: The number associated with each employee is apparently his or her department. The enumeration in the code shows this.
I tried to write the program but I don't know what to put in "SWITCH" loop. Here is what i have so far.
C:
#include <iostrean>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
ifstream in_stream;
ofstream out_stream;
in_stream.open("Employee.dat");
if (in_stream.fail())
{
cout << "Input file failed to open.\n";
exit(1);
}
out_stream.open(("Managers.dat", ios::app), ("Marketing.dat", ios::app), ("Developers.dat", ios::app), ("Testers.dat", ios::app);
if (out_stream.fail())
{
cout << "Output file failed to open.\n";
exit(1);
}
string first_name, last_name;
enum department { Managers = 1, Marketing = 2, Developers = 3, Testers = 4 };
im_stream >> first_name >> last_name >> department;
while (!in_stream.eof())
{
switch (department)
{
number '1';
out_stream << "
Last edited by a moderator: