Home › Forums › C Programming › inventory mngmt in C
- This topic has 1 reply, 2 voices, and was last updated 15 years, 11 months ago by GWILouisaxwzkla.
Viewing 1 reply thread
- AuthorPosts
- December 3, 2008 at 6:23 am #2162DoreenFeganParticipant
:x please ive me coding of inventory management project in C language full coding…..please help..
- December 4, 2008 at 12:36 am #3487GWILouisaxwzklaParticipant
Not sure exactly what you need , but here is something similar with an array of structs and a library inventory:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418<br />/****************************************************************<br />* File Name : c:programshelpshell.cpp<br />* Date : May,14,2007<br />* Comments : new project<br />* Compiler/Assembler :<br />*<br />*<br />*<br />*<br />*<br />* Program Shell Generated At: 1:40:06 p.m.<br />=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/<br /><br /><br />#include <br />#include <br />//#include <br />//#include <br />//#include <br />//#include <br /><br />using namespace std;<br /><br />struct PERSON<br />{<br /><br />string firstName;<br />string lastName;<br />string address;<br />string phoneNumber;<br />};<br /><br /><br />//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FUNCTION PROTOTYPES @@@@@@@@@@@@@@@@@@@@@@@@@@<br /><br />void addPerson ( PERSON & thisPerson );<br />void getPerson ( PERSON & thisPerson );<br />bool findPerson ( string & firstName );<br />bool findPerson ( string & firstName , string & lastName );<br /><br />void printBook ( void );<br />bool checkDuplicate ( PERSON & personToCheck );<br />bool insertAfter ( PERSON & personToAdd , int index );<br /><br /><br />//##################################################################################<br /><br /><br />//>>>>>>>>>>>>>>>>>>>>>>>> GLOBAL DATA <<<<<<<<<<<<<<<<<<<<<<<<<<br />const int MAX_PEOPLE = 3;<br />PERSON addressBook [ MAX_PEOPLE ] ;<br />int arrayIndex;<br />int itemsInAddressBook = 0;<br />//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<br /><br /><br />//main function ******************************<br /><br />int main ( )<br />{<br /><br />arrayIndex = 0;<br />PERSON temp;<br />char choice;<br />string firstName , lastName;<br /><br />do<br />{<br />cout << endl;<br />cout << "menu ***********" << endl;<br />cout << "1. add person" << endl;<br />cout << "2. get person " << endl;<br />cout << "3. find person ( full name ) " << endl;<br />cout << "4. find person ( first name ) " << endl;<br />cout << "5. print address book " << endl;<br />cout << "6. insert after another item " << endl;<br />cout << "7. quit" << endl;<br /><br />cout << endl << "enter choice ";<br /><br /><br />cin >> choice;<br />while ( choice != '1' && choice != '2' && choice != '3' && choice != '4' && choice != '5'<br />&& choice != '6' && choice != '7' )<br />{<br />cout << "Bad choice ( 1,2,3,4,5,6,7 ) , enter choice : ";<br />cin >> choice;<br />}<br />switch ( choice )<br />{<br />case '1':<br />{<br />cout << endl;<br />cout << "enter first name: ";<br />cin >> temp.firstName;<br />cout << "enter last name: ";<br />cin >> temp.lastName;<br />cout << "enter address ( $ to end input ): ";<br />cin.get();<br />getline ( cin , temp.address , '$' );<br />cout << "enter phone number: ";<br />cin >> temp.phoneNumber;<br />addPerson ( temp );<br />};<br />break;<br />case '2':<br />{<br />getPerson ( temp );<br />cout << endl;<br />cout << "name retrieved :";<br />cout << "first name : " << temp.firstName << endl;<br />cout << "last name : " << temp.lastName << endl;<br />cout << "address : " << temp.address << endl;<br />cout << "phone number : " << temp.phoneNumber << endl;<br />};<br />break;<br />case '4':<br />{<br />cout << "enter first name: ";<br />cin >> firstName;<br />if ( findPerson ( firstName ) )<br />cout << "name is in the address book " << endl;<br />else<br />cout << "name is not in the address book " << endl;<br />};<br />break;<br />case '3':<br />{<br />cout << "enter first name: ";<br />cin >> firstName;<br />cout << "enter last name: ";<br />cin >> lastName;<br /><br /><br />if ( findPerson ( firstName , lastName ) )<br />cout << "name is in the address book " << endl;<br />else<br />cout << "name is not in the address book " << endl;<br />};<br />break;<br />case '5':<br />{<br />printBook ( );<br />};<br />break;<br />case '6':<br />{<br />cout << "enter first name: ";<br />cin >> temp.firstName;<br />cout << "enter last name: ";<br />cin >> temp.lastName;<br />cout << "enter index to enter after : ";<br />int index;<br />cin >> index;<br />insertAfter ( temp , index );<br />};<br />break;<br />};<br />}<br />while ( choice != '7' );<br /><br /><br /><br /><br />return 0 ;<br />}<br /><br /><br />/******************************* FUNCTION DEFINITION ******************************<br /><br />Name : addPerson<br />Parameters :<br /><br />thisPerson a(n) PERSON & ( PERSON & )<br /><br /><br />Returns: Void type<br />Comments:<br /><br /><br /><br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br />void addPerson ( PERSON & thisPerson )<br />{<br /><br /><br /><br />if ( arrayIndex >= MAX_PEOPLE )<br />arrayIndex = 0;<br /><br />if ( itemsInAddressBook < MAX_PEOPLE )<br />itemsInAddressBook ++;<br /><br />if ( checkDuplicate ( thisPerson ) == true )<br />{<br />cout << endl << "item already in data base ! " << endl;<br />return;<br />}<br /><br /><br />addressBook [ arrayIndex ].firstName = thisPerson.firstName;<br />addressBook [ arrayIndex ].lastName = thisPerson.lastName;<br />addressBook [ arrayIndex ].address = thisPerson.address;<br />addressBook [ arrayIndex ].phoneNumber = thisPerson.phoneNumber;<br /><br />arrayIndex ++;<br />return;<br />}<br />/******************************* FUNCTION DEFINITION ******************************<br /><br />Name : getPerson<br />Parameters :<br /><br />thisPerson a(n) PERSON & ( PERSON & )<br /><br /><br />Returns: Void type<br />Comments:<br /><br /><br /><br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br />void getPerson ( PERSON & thisPerson )<br />{<br /><br /><br /><br />if ( itemsInAddressBook == 0 )<br />{<br />cout << "adress book empty" << endl;<br />return;<br />}<br /><br />if ( arrayIndex >= MAX_PEOPLE )<br />arrayIndex = 0;<br /><br /><br />thisPerson.firstName = addressBook [ arrayIndex ].firstName;<br />thisPerson.lastName = addressBook [ arrayIndex ].lastName ;<br />thisPerson.address = addressBook [ arrayIndex ].address;<br />thisPerson.phoneNumber = addressBook [ arrayIndex ].phoneNumber;<br />arrayIndex ++;<br />if ( arrayIndex >= MAX_PEOPLE )<br />arrayIndex = 0;<br />if ( itemsInAddressBook < MAX_PEOPLE )<br />itemsInAddressBook ++;<br /><br />return;<br />}<br />/******************************* FUNCTION DEFINITION ******************************<br /><br />Name : findPerson<br />Parameters :<br /><br />firstName a(n) string & ( string & )<br /><br /><br />Returns: user defined type , bool<br /><br />Comments:<br /><br /><br /><br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br />bool findPerson ( string & firstName )<br />{<br />int i = 0;<br /><br />while ( i < itemsInAddressBook )<br />{<br />if ( firstName == addressBook [ i ].firstName )<br />return true;<br />i ++;<br />}<br />return false;<br />}<br />/******************************* FUNCTION DEFINITION ******************************<br /><br />Name : findPerson<br />Parameters :<br /><br />firstName a(n) string & ( string & ) ,<br />lastName a(n) string & ( string & )<br /><br /><br />Returns: user defined type , bool<br /><br />Comments:<br /><br /><br /><br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br />bool findPerson ( string & firstName , string & lastName )<br />{<br /><br />int i = 0;<br /><br />while ( i < itemsInAddressBook && i < MAX_PEOPLE )<br />{<br />if ( firstName == addressBook [ i ].firstName && lastName == addressBook [ i ].lastName )<br />return true;<br />i ++;<br />}<br />return false;<br />}<br />/******************************* FUNCTION DEFINITION ******************************<br /><br />Name : printBook<br />Parameters :<br /><br />void ( void )<br /><br /><br />Returns: Void type<br />Comments:<br /><br /><br /><br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br />void printBook ( void )<br />{<br />int i = 0;<br />while ( i < itemsInAddressBook && i < MAX_PEOPLE )<br />{<br />cout << i << ". " << addressBook [ i ].firstName<br /><< " " << addressBook [ i ].lastName<br /><< " " << addressBook [ i ].address<br /><< " " << addressBook [ i ]. phoneNumber << endl;<br />i ++;<br />}<br />return;<br />}<br />/******************************* FUNCTION DEFINITION ******************************<br /><br />Name : checkDuplicate<br />Parameters :<br /><br />personToCheck a(n) person & ( person & )<br /><br /><br />Returns: user defined type , bool<br /><br />Comments:<br /><br /><br /><br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br />bool checkDuplicate ( PERSON & personToCheck )<br />{<br /><br />int i = 0;<br />while ( i < itemsInAddressBook && i < MAX_PEOPLE )<br />{<br />if ( personToCheck.firstName == addressBook [ i ].firstName<br />&& personToCheck.lastName == addressBook [ i ].lastName )<br />return true;<br />i ++;<br />}<br /><br /><br />return false;<br />}<br />/******************************* FUNCTION DEFINITION ******************************<br /><br />Name : insertAfter<br />Parameters :<br /><br />personToAdd a(n) person & ( person & ) ,<br />index a(n) int ( int )<br /><br /><br />Returns: user defined type , bool<br /><br />Comments:<br /><br /><br /><br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br />bool insertAfter ( PERSON & personToAdd , int index )<br />{<br /><br /><br />if ( checkDuplicate ( personToAdd ) == true )<br />{<br />cout << endl << "item already in data base ! " << endl;<br />return false;<br />}<br />if ( index > itemsInAddressBook )<br />{<br /><br />addressBook [ arrayIndex ].firstName = personToAdd.firstName;<br />addressBook [ arrayIndex ].lastName = personToAdd.lastName;<br />addressBook [ arrayIndex ].address = personToAdd.address;<br />addressBook [ arrayIndex ].phoneNumber = personToAdd.phoneNumber;<br />arrayIndex ++;<br />if ( arrayIndex >= MAX_PEOPLE )<br />arrayIndex = 0;<br />if ( itemsInAddressBook > MAX_PEOPLE )<br />itemsInAddressBook ++;<br />}<br />else if ( index < itemsInAddressBook )<br />{<br /><br />addressBook [ index + 1 ].firstName = personToAdd.firstName;<br />addressBook [ index + 1 ].lastName = personToAdd.lastName;<br />addressBook [ index + 1 ].address = personToAdd.address;<br />addressBook [ index + 1 ].phoneNumber = personToAdd.phoneNumber;<br /><br />if ( itemsInAddressBook <= MAX_PEOPLE )<br />itemsInAddressBook ++;<br /><br />}<br />return true;<br />}<br /><br /><br />
- AuthorPosts
Viewing 1 reply thread
- The forum ‘C Programming’ is closed to new topics and replies.