Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 6th, 2003, 07:07 AM
ngvepforever ngvepforever is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 2 ngvepforever User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
C++ problem Help!

Hi I have been working in this program( C++). The program is a system that
stores an employee's firstname , lastname, five digit number, the
department they work in and their annual salary. There are a maximum
of teen employees in the organization.

The program should allow me to add an employee , but it should warn me
if I am trying to create two identical employees, it should be able to
delete a current employee or update an existing employee's
information. The data is saved in the file "employee2.txt" when shutdown
and retrieves the data from the same file when started. The format of
the file is

11111 Firstname Lastname Departmentname $10,000

Now up to this point I am able to add a new employee, but where the
problem comes is when trying to delete, update or compare an employee.
I think I should use a loop to search thru the file in order to get
the name of the employee to delete, or to update, if this works , the
loop should also allow me to compare two employees. But I am confused
becasue I don't know if I should use the get function in order to do
that. I cannot use arrays pointers or strings because in my class I haven't
gotten to that point. Right now I am using classes to do this problem

This is what I got so far
#include<iostream>
#include<fstream>
#include<iomanip>

using namespace std;

class INFO
{
private:

int memberid;
char firstname[10];
char lastname[10];
char departname[15];
char annualsalary[10];

public:

void addemployee(ofstream& out_stream, INFO employee);

void update(ofstream& out_stream, ifstream& in_stream, INFO
employee);
};

int main()
{
ifstream in_stream;
in_stream.open("employment2.txt");
ofstream out_stream;
out_stream.open("employment2.txt",ios::app);
INFO employee;
char choice;
cout<<"Enter your choice of preference.\n";
cin>>choice;

switch(choice)
{

case'A':

employee.addemployee(out_stream, employee);

break;

case 'B':

employee.update(out_stream, in_stream, employee);

break;


}

out_stream.close();
return 0;
}

//Uses iostream
//Uses fstream
//Uses uses iomanip

void INFO::addemployee(ofstream& out_stream, INFO employee)
{

cout<<"Please enter a new employee to be written in the file.\n";
cout<<"in this format 99999 firstname lastname departmentname
$10,000.\n";
cin>>employee.memberid;
cin>>employee.firstname;
cin>>employee.lastname;
cin>>employee.departname;
cin>>employee.annualsalary;

cout<<employee.memberid<<setw(10)<<employee.firstname<<setw(10)<<employee.lastname<<setw(15)<<employee.departname<<setw(10)<<employee.annualsalary<<endl;
out_stream<<employee.memberid<<setw(10)<<employee.firstname<<setw(10)<<employee.lastname<<setw(15)<<employee.departname<<setw(10)<<employee.annualsalary<<endl;

}


//Uses iostream
//Uses fstream
//Uses iomanip

void INFO::update(ofstream& out_stream, ifstream& in_stream, INFO
employee)

{//This is where I have the problem!
}



I need the function definitions to compare that I am not creating two similar employees and the function to update and delete a current employee, I also need to include constructors to initiliaze my variable employee and I repeat I cannot use strings or arrays in this problem.
Regards

Reply With Quote
  #2  
Old November 6th, 2003, 07:09 AM
ngvepforever ngvepforever is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 2 ngvepforever User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
In case you....

In case you can't understand I will post the original problem

I am the owner of a small business and am in need of a simple system to keep track of information about my employees. The system needs to store the employee’s name(first, last) their employee number ( a 5 digit number) the department they work in and the annual salary. The system should also be able to compare two employees and warn me if I am trying to create two identical employees. Currently there are a maximum of ten employees in the organization.

I would like for you to provide a text based user interface to allow me to add a new employee to the system, delte a current employee, or update an existing employee’s information. I am on a tight budget, so please minimize the cost of the system by reusing any parts from existing systems wherever possible. I would like to call the system EmployeeTracker and would like it to save the data in a file (employee.dat) when shutdowm and retrieve the data from the file when started. The format of the file should be as follows, one employee per line.


99999 Firstname Lastname Departmentname $10,000

This problem has been brain-torturing me for a week and I need it done real bad so If any of you guys want to help out and earn a few bucks please check my question in Google answers

URL

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > C++ problem Help!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT