Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
Chemistry
Biology and Medical
Earth Sciences
Computer Science
Computing and Technology
DIY Projects
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
Chemistry
Biology and Medical
Earth Sciences
Computer Science
Computing and Technology
DIY Projects
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Other Sciences
Programming and Computer Science
How to Parse and Output Employee Data from a File Based on Department
Reply to thread
Message
[QUOTE="idle_09, post: 1793115, member: 119313"] 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 [COLOR=rgb(44, 130, 201)][B]Mentor note[/B]: The number associated with each employee is apparently his or her department. The enumeration in the code shows this.[/COLOR] I tried to write the program but I don't know what to put in "SWITCH" loop. Here is what i have so far. [code=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 << "[/code] [/QUOTE]
Insert quotes…
Post reply
Forums
Other Sciences
Programming and Computer Science
How to Parse and Output Employee Data from a File Based on Department
Back
Top