d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > C++ Program
Add Reply New Topic New Poll
Member
Posts: 77,595
Joined: Jun 23 2008
Gold: 0.64
Sep 28 2013 05:29pm
i need to use structure

first i will ask the users what he wants to do:
enter new employee(part time,full time)(add first name,last name,idnumber,gender,salaray)
check all employees
or quit
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 28 2013 05:32pm
sounds like a good starting point. now what do you need help with?
Member
Posts: 77,595
Joined: Jun 23 2008
Gold: 0.64
Sep 28 2013 05:36pm
i need if else to see which option the users picked
the arrays to store the info for new users
and array to check the records
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 28 2013 05:54pm
ok...and what part of that do you need help with?
Member
Posts: 77,595
Joined: Jun 23 2008
Gold: 0.64
Sep 28 2013 06:42pm
i need help with struct
getting the info about employee and storing it
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 28 2013 07:01pm
what code do you have so far?

here are examples for how to do a struct:
http://www.cplusplus.com/doc/tutorial/structures/

the attributes you want are part time/full time, first name,last name,idnumber,gender,salary

here are some examples of how to get input from a user:
http://www.cplusplus.com/doc/tutorial/basic_io/

here are some examples of how to use arrays:
http://www.cplusplus.com/doc/tutorial/arrays/
Member
Posts: 77,595
Joined: Jun 23 2008
Gold: 0.64
Sep 28 2013 07:03pm
#include <iostream>
using namespace std;

int main ()
{
typedef struct employee
{
public:
char fname[20];
char lname[20];
int idnumber ;
char gender ;
int salary ;
};

employee ftemployee[100], ptemployee[100] ;



int n;

cout << "\n==================== ";
cout << "\n<1>Press 1 to add new employee ";
cout << "\n<2>Press 2 to print All Emplyoees ";
cout << "\n<3>Enter anything to quit: ";
cout << "\n==================== \n";
cin >> n;

if ( n==1 ){

cout << "/Enter first name: " << ftemployee.fname;
cout << "/Enter last name: " << ftemployee.laname;
cout << "/Enter id number: " << ftemployee.idnum;
cout << "/Enter gender: " << ftemployee.gender;
cout << "/Enter salary: " << ftemployee.salary;




}
else if (n==2 ){

cout << "\nyou enteredt 2 \n";
}
else {

cout << "\nNot matching any of the choices \n";
cout << "You entered---- " << n << "\n";
}

system("pause");
return 0;
}


i was testing the if else loop so i have some parts left from that
Member
Posts: 35,456
Joined: Jan 25 2009
Gold: 1,173.00
Sep 29 2013 12:03am
See I told you someone would answer. :thumbsup:
Member
Posts: 77,595
Joined: Jun 23 2008
Gold: 0.64
Sep 29 2013 02:19pm
Quote (NinjaSushi2 @ Sep 29 2013 02:03am)
See I told you someone would answer.  :thumbsup:


yep :)
Member
Posts: 77,595
Joined: Jun 23 2008
Gold: 0.64
Oct 9 2013 05:26pm
Quote (carteblanche @ Sep 28 2013 09:01pm)
what code do you have so far?

here are examples for how to do a struct:
http://www.cplusplus.com/doc/tutorial/structures/

the attributes you want are part time/full time, first name,last name,idnumber,gender,salary

here are some examples of how to get input from a user:
http://www.cplusplus.com/doc/tutorial/basic%5Fio/

here are some examples of how to use arrays:
http://www.cplusplus.com/doc/tutorial/arrays/


thanks
forgot to udpate this thread
did it
had to use few more if statements
and put (1) after struct
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll