Need help C++ inventory project

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2007
Posts: 1
Reputation: jkrege03 is an unknown quantity at this point 
Solved Threads: 0
jkrege03 jkrege03 is offline Offline
Newbie Poster

Need help C++ inventory project

 
0
  #1
Jun 3rd, 2007
Hi, I'm in need of some help on a project I'm doing for a class. In this project were creating an inventory management system for a soda pop company. The menu's and initial part of the program has already been created, my job is to take three fields, sku, quantity, and price and field reports from them. I need to take one sku, and print a report listing sku and quantity, or If the user wants a total report print all skus, total quantity, and total sale price amount. If a sku is under a quantity of 24, than create a flag for that sku. Here is the code we've created for the program.
  1. /*
  2. ************************************************** ***********************
  3. * *
  4. * Main menu and function calls for soft drink inventory *
  5. * *
  6. * Team project for CS218a :: Mr. Steven King *
  7. * *
  8. * Team Members: Andrew Gonyea, Rick Hedden, James Kreger *
  9. * *
  10. ************************************************** ***********************
  11. */
  12.  
  13. #include <iostream>
  14. #include <string>
  15. #include <fstream>
  16. #include <iomanip>
  17. #include <stdio.h>
  18. #include <time.h>
  19. #include <vector>
  20. #include <stdlib.h>
  21. #define SIZE 26
  22. using namespace std;
  23. using std::string;
  24.  
  25. //variable definitions
  26. int l = 0;
  27. int i = 0;
  28.  
  29. // data structures
  30. struct productType
  31. {
  32. string brand;
  33. string flavor;
  34. string descript;
  35. string size;
  36. string SKU;
  37. double deposit;
  38. };
  39.  
  40. productType drink[1000];
  41.  
  42. struct costType
  43. {
  44. string sku;
  45. double cost;
  46. double salePrice;
  47. };
  48. costType drinkCost[3000];
  49.  
  50. struct companyType
  51. {
  52. string VID;
  53. string coName;
  54. string contactName;
  55. string address1;
  56. string address2;
  57. string city;
  58. string state;
  59. string zip;
  60. string phone;
  61. string fax;
  62. };
  63. companyType vendor[1000];
  64.  
  65. struct invenType
  66. {
  67. string sku;
  68. int quantity;
  69. };
  70.  
  71. invenType inventoryLine[1000];
  72.  
  73. void makeLine(int); // function declarations
  74.  
  75. //void updateInfo (productType drink[],companytype vendor[]);
  76. char updateProduct(productType drink[]);
  77. char displayProduct(productType drink[]);
  78. char updateVendor(companyType vendor[]);
  79. char displayVendor(companyType vendor[]);
  80. char updateMenu();
  81. void makeLine(int l);
  82. char makeMenu();
  83.  
  84. ///////////////////////// MAIN FUNCTION /////////////////////////////////////////////
  85. int main ()
  86. {
  87. char select;
  88. select = 'i';
  89.  
  90. //set length of line
  91. int l;
  92. l = 55;
  93.  
  94. //Make the main menu
  95.  
  96. while(select != 'q' && select != 'Q')
  97. {
  98. select = makeMenu();
  99. if(select == 'c' || select == 'C')
  100. {
  101. select = 'C';
  102. //replace the following line with the call to the check() function
  103. cout << "\t\tBegin Inventory Check" << endl;
  104. }
  105.  
  106. if(select == 'a' || select == 'A')
  107. {
  108. select = 'A';
  109. //replace the following line with the call to the addProduct() function
  110. cout << "\t\tBegin Inventory Addition" << endl;
  111. }
  112.  
  113. if(select == 's' || select == 'S')
  114. {
  115. select = 'S';
  116. //replace the following line with the call to the sellProduct() function
  117. cout << "\t\tBegin Sale" << endl;
  118. }
  119.  
  120. if(select == 'u' || select == 'U')
  121. {
  122. select = 'U';
  123. char changeAnother;
  124. changeAnother = 'R';
  125. char updateChoice = 'q';
  126. cout << "\t\tBegin update function: " << endl << flush;
  127. system ("CLS");
  128. updateChoice = updateMenu();
  129. if(updateChoice == 'v' || updateChoice == 'V')
  130. {
  131. updateChoice = 'V';
  132. cout << "\t\tBegin Vendor Update" << flush;
  133. while(changeAnother == 'R')
  134. {
  135. changeAnother = updateVendor(vendor);
  136. }
  137. }
  138. if(updateChoice == 'd' || updateChoice == 'D')
  139. {
  140. updateChoice = 'D';
  141. cout << "\t\tDisplay Vendor data" << flush;
  142. changeAnother = displayVendor(vendor);
  143. }
  144. if(updateChoice == 'r' || updateChoice == 'R')
  145. {
  146. updateChoice = 'R';
  147. cout << "\t\tReport Product data" << flush;
  148. changeAnother = displayProduct(drink);
  149. }
  150. if(updateChoice == 'p' || updateChoice == 'P')
  151. {
  152. updateChoice = 'P';
  153. cout << "\t\tBegin Product Update" << flush;
  154. while(changeAnother == 'R')
  155. {
  156. changeAnother = updateProduct(drink);
  157. }
  158. }
  159. }
  160. if(select == 'q' || select == 'Q')
  161. {
  162. return 0;
  163. }
  164. } // end while loop
  165. return 0;
  166. }
  167.  
  168.  
  169. ////////////////////// CALLED MENU FUNCTIONS ///////////////////////////////////
  170. char makeMenu()
  171. {
  172. int i;
  173. char branch;
  174. branch = 'i';
  175. cout << flush;
  176. system ("CLS");
  177. makeLine(65);
  178.  
  179. for(i=0;i<2;i++)
  180. {
  181. cout << endl;
  182. }
  183. cout << "\t\t" << "Soft-Drink-Co -:- Inventory Control System " << endl << endl;
  184. time_t ltime;
  185. wchar_t buf[size];
  186. errno_t err;
  187. time( &ltime );
  188.  
  189. err = _wctime_s( buf, SIZE, &ltime );
  190. if (err != 0)
  191. {
  192. printf("Invalid Arguments for _wctime_s. Error Code: %d\n", err);
  193. }
  194. wprintf( L"\t\tToday is %s\n", buf );
  195.  
  196. for(i=0;i<2;i++)
  197. {
  198. cout << endl;
  199. }
  200. makeLine(65);
  201.  
  202. cout << "\t\t" << "Enter a single-letter command" << endl << endl;
  203. cout << "\t\t" << "C - Check inventory" << endl;
  204. cout << "\t\t" << "A - Add product to inventory" << endl;
  205. cout << "\t\t" << "S - Sell product in inventory" << endl;
  206. cout << "\t\t" << "U - Update or display product/vendor info" << endl;
  207. cout << "\t\t" << "Q - Quit program" << endl;
  208. cout << endl << "\t\t" << "Please enter your selection now: ";
  209. cin >> branch;
  210. return branch;
  211. }
  212.  
  213. void makeLine(int l)
  214. {
  215. int p;
  216. cout << " ";
  217. for(p=0;p<l;p++)
  218. {
  219. cout << "*";
  220. }
  221. cout << endl;
  222. return;
  223. }
  224.  
  225. ////////////////////// CALLED APPLICATION FUNCTION ////////////////////////////
  226. char updateMenu()
  227. {
  228. int i;
  229. char branch,updateFlag;
  230. branch = 'i';
  231. makeLine(65);
  232. for(i=0;i<2;i++)
  233. {
  234. cout << endl;
  235. }
  236. cout << "\t\t" << "Soft-Drink-Co -:- Inventory Control System " << endl << endl;
  237. time_t ltime;
  238. wchar_t buf[size];
  239. errno_t err;
  240. time( &ltime );
  241.  
  242. err = _wctime_s( buf, SIZE, &ltime );
  243. if (err != 0)
  244. {
  245. printf("Invalid Arguments for _wctime_s. Error Code: %d\n", err);
  246. }
  247. wprintf( L"\t\tToday is %s\n", buf );
  248.  
  249. for(i=0;i<2;i++)
  250. {
  251. cout << endl;
  252. }
  253. makeLine(65);
  254.  
  255. cout << endl << endl;
  256. cout << "\t\tWould you like to update Vendor or Product information? " << endl;
  257. cout << "\t\t" << "Enter a single-letter command" << endl << endl;
  258. cout << "\t\t" << "V - Update Vendor info" << endl;
  259. cout << "\t\t" << "D - Display Vendor data" << endl;
  260. cout << "\t\t" << "P - Update product info" << endl;
  261. cout << "\t\t" << "R - Report proudct info" << endl;
  262. cout << "\t\t" << "Q - Return to main menu" << endl;
  263. cout << endl << "\t\t" << "Please enter your selection now: ";
  264. cin >> updateFlag;
  265. return updateFlag;
  266. }
  267.  
  268. //////////////////////////// Function updates Vendor Data //////////////////////
  269. char updateVendor(companyType vendor[])
  270. {
  271. // declare variables
  272. char pause;
  273. char vendorUpdateContinue = 'Y';
  274. char recordUpdateContinue = 'Y';
  275. string spacer;
  276. string searchVID;
  277. string searchNameString;
  278. string tempString;
  279. int foundItem;
  280. int choiceNum = 0;
  281. int selectItem = 0;
  282. int maxRecord;
  283. int candidateRecord[20];
  284.  
  285. // define input files
  286. ifstream vendorFile;
  287. ofstream newVendorFile;
  288. vendorFile.open("vendorData.txt");
  289. if (!vendorFile) //test for presence of productFile
  290. {
  291. cout << "\t\tUnable to open vendor DATA file." << endl;
  292. cout << "\t\tPlease contact developer." << endl;
  293. cout << "\t\tThis program will end." << endl;
  294. return 'X';
  295. }
  296. system ("CLS");
  297. cin.ignore(100,'\n');
  298. for (i = 0;i < 1000;i++)
  299. {
  300. getline(vendorFile,vendor[i].VID);
  301. getline(vendorFile,vendor[i].coName);
  302. getline(vendorFile,vendor[i].contactName);
  303. getline(vendorFile,vendor[i].address1);
  304. getline(vendorFile,vendor[i].address2);
  305. getline(vendorFile,vendor[i].city);
  306. getline(vendorFile,vendor[i].state);
  307. getline(vendorFile,vendor[i].zip);
  308. getline(vendorFile,vendor[i].phone);
  309. getline(vendorFile,vendor[i].fax);
  310. }
  311. //vendorFile.close();
  312. cout << "\t\tRecent vendor entries:" << endl << endl;
  313. for (i = 0;i < 1000;i++)
  314. {
  315. if(vendor[i].VID.empty())
  316. {
  317. maxRecord = i;
  318. i = 1000;
  319. }
  320. else
  321. {
  322. cout << "\t\t" << vendor[i].VID << "\t\t"
  323. << vendor[i].coName << endl;
  324. }
  325. }
  326. cout << endl << "\t\tMake a note of Vendor ID before proceding. " << endl << endl << "\t\t";
  327. system("PAUSE");
  328. while(vendorUpdateContinue=='Y')
  329. {
  330. system ("CLS");
  331. makeLine(65);
  332. cout << endl;
  333. cout << "\t\tEnter Vendor ID of record to change, " << endl;
  334. cout << "\t\tor, to search by company name, enter \'??\'" << endl;
  335. cout << "\t\tto abandon ALL changes and return" << endl;
  336. cout << "\t\tto the main menu enter 9999." << endl << endl;
  337. makeLine(65);
  338. cout << endl << endl << "\t\t";
  339. getline(cin,searchVID);
  340. if(searchVID=="9999")
  341. {
  342. return 'X';
  343. }
  344. if(searchVID=="??") // VID unknown, search by XX*
  345. {
  346. system ("CLS");
  347. makeLine(65);
  348. cout << endl << endl;
  349. cout << "\t\tSearch for vendor data by first three " << endl;
  350. cout << "\t\tletters of company name or enter 9999 to" << endl;
  351. cout << "\t\tabandon ALL changes and return to main menu." << endl;
  352. cout << endl << endl;
  353. makeLine(65);
  354. cout << "\t\t";
  355. cin.ignore(100,'\n');
  356. getline(cin,searchNameString);
  357. cout << searchNameString;
  358. system ("CLS");
  359. makeLine(65);
  360. cout << endl;
  361. cout << "\t\tMatching records: " << endl;
  362. for(i=0;i < maxRecord;i++)
  363. {
  364. if(vendor[i].coName.substr(0,3)==searchNameString)
  365. {
  366. candidateRecord[choicenum]= i;
  367. choiceNum++;
  368. cout << "\t\t" << choiceNum << ": " << vendor[i].coName;
  369. }
  370. }
  371. makeLine(56);
  372. if(choiceNum==0)
  373. {
  374. cout << endl << "\t\tNo records found." << endl;
  375. break;
  376. }
  377. else if(choiceNum==1)
  378. {
  379. cout <<endl << "\t\tJust one company matches search: " << vendor[0].coName << endl;
  380. foundItem = 0;
  381. }
  382. cout << endl;
  383. cout << "\t\tEnter the line number of the record you want to update: ";
  384. cin >> selectItem;
  385. foundItem = candidateRecord[selectitem];
  386. }
  387. for(i=0;i<1000;i++)
  388. {
  389. if(vendor[i].VID==searchVID)
  390. {
  391. foundItem = i;
  392. i = maxRecord;
  393. }
  394. }
  395. while(recordUpdateContinue=='Y')
  396. {
  397. system ("CLS");
  398. makeLine(65);
  399. cout << endl << endl;
  400. cout << "\t\t1. " << vendor[founditem].VID << endl;
  401. cout << "\t\t2. " << vendor[founditem].coName << endl;
  402. cout << "\t\t3. " << vendor[founditem].contactName << endl;
  403. cout << "\t\t4. " << vendor[founditem].address1 << endl;
  404. cout << "\t\t5. " << vendor[founditem].address2 << endl;
  405. cout << "\t\t6. " << vendor[founditem].city << endl;
  406. cout << "\t\t7. " << vendor[founditem].state << endl;
  407. cout << "\t\t8. " << vendor[founditem].zip << endl;
  408. cout << "\t\t9. " << vendor[founditem].phone << endl;
  409. cout << "\t\t10. " << vendor[founditem].fax << endl;
  410. cout << endl;
  411. makeLine(65);
  412. cout << "\t\tEnter the line number you would like to update" << endl;
  413. cout << "\t\tor enter 0 to abandon changes and return to menu.\t\t ";
  414. cin >> selectItem;
  415. cin.ignore(100,'\n');
  416. switch (selectItem)
  417. {
  418. case 0:
  419. break;
  420. case 1:
  421. {
  422. cout << "\t\tEnter new data for "
  423. << "Vendor ID: ";
  424. getline(cin,vendor[founditem].VID);
  425. break;
  426. }
  427. case 2:
  428. {
  429. cout << "\t\tEnter new data for "
  430. << "Vendor company name: ";
  431. getline(cin,vendor[founditem].coName);
  432. break;
  433. }
  434. case 3:
  435. {
  436. cout << "\t\tEnter new data for "
  437. << "Vendor contact name: ";
  438. getline(cin,vendor[founditem].contactName);
  439. break;
  440. }
  441. case 4:
  442. {
  443. cout << "\t\tEnter new data for "
  444. << "Vendor address line 1: ";
  445. getline(cin,vendor[founditem].address1);
  446. break;
  447. }
  448. case 5:
  449. {
  450. cout << "\t\tEnter new data for "
  451. << "Vendor address line 2: ";
  452. getline(cin,vendor[founditem].address2);
  453. break;
  454. }
  455. case 6:
  456. {
  457. cout << "\t\tEnter new data for "
  458. << "Vendor city: ";
  459. getline(cin,vendor[founditem].city);
  460. break;
  461. }
  462. case 7:
  463. {
  464. cout << "\t\tEnter new data for "
  465. << "Vendor state: ";
  466. getline(cin,vendor[founditem].state);
  467. break;
  468. }
  469. case 8:
  470. {
  471. cout << "\t\tEnter new data for "
  472. << "Vendor zip code: ";
  473. getline(cin,vendor[founditem].zip);
  474. break;
  475. }
  476. case 9:
  477. {
  478. cout << "\t\tEnter new data for "
  479. << "Vendor phone: ";
  480. getline(cin,vendor[founditem].phone);
  481. break;
  482. }
  483. case 10:
  484. {
  485. cout << "\t\tEnter new data for "
  486. << "Vendor Fax: ";
  487. getline(cin,vendor[founditem].fax);
  488. break;
  489. }
  490. } // end of switch strucure
  491. cout << endl << "\t\tMake additional changes to same record? (y/n) ";
  492. cin.ignore(100,'\n');
  493. cin >> recordUpdateContinue;
  494. } // end record update while loop
  495. cout << endl << "\t\tMake changes to a different record? (y/n) ";
  496. cin >> vendorUpdateContinue;
  497. if(vendorUpdateContinue == 'y' || vendorUpdateContinue == 'Y')
  498. {
  499. vendorUpdateContinue = 'Y';
  500. }
  501. } // end of OTHER WHILE loop
  502. /////////////////// routine saves vendor data file
  503. newVendorFile.open("VendorData.txt");
  504. for(i=0; i<1000; i++)
  505. {
  506. if(vendor[i].VID.empty())
  507. {
  508. i = 1000;
  509. break;
  510. }
  511. else
  512. {
  513. newVendorFile << vendor[i].VID << endl
  514. << vendor[i].coName << endl
  515. << vendor[i].contactName << endl
  516. << vendor[i].address1 << endl
  517. << vendor[i].address2 << endl
  518. << vendor[i].city << endl
  519. << vendor[i].state << endl
  520. << vendor[i].zip << endl
  521. << vendor[i].phone << endl
  522. << vendor[i].fax << endl;
  523. }
  524. } // end of new vendor data file write loop
  525. newVendorFile.close();
  526. return 'X';
  527. }
  528. /////////////////// routine displays vendor data //////////////////////
  529. char displayVendor(companyType vendor[])
  530. {
  531. // declare variables
  532. char vendorUpdateContinue = 'Y';
  533. char vendorDisplayContinue = 'Y';
  534. char recordUpdateContinue = 'Y';
  535. char recordDisplayContinue = 'Y';
  536. string spacer;
  537. string searchVID;
  538. string searchNameString;
  539. string tempString;
  540. int foundItem;
  541. int choiceNum = 0;
  542. int selectItem = 0;
  543. int maxRecord;
  544.  
  545. // define input files
  546. ifstream vendorFile;
  547. ofstream newVendorFile;
  548. vendorFile.open("vendorData.txt");
  549. if (!vendorFile) //test for presence of productFile
  550. {
  551. cout << "\t\tUnable to open vendor DATA file." << endl;
  552. cout << "\t\tPlease contact developer." << endl;
  553. cout << "\t\tThis program will end." << endl;
  554. return 'X';
  555. }
  556. system ("CLS");
  557. cin.ignore(100,'\n');
  558. for (i = 0;i < 1000;i++)
  559. {
  560. getline(vendorFile,vendor[i].VID);
  561. getline(vendorFile,vendor[i].coName);
  562. getline(vendorFile,vendor[i].contactName);
  563. getline(vendorFile,vendor[i].address1);
  564. getline(vendorFile,vendor[i].address2);
  565. getline(vendorFile,vendor[i].city);
  566. getline(vendorFile,vendor[i].state);
  567. getline(vendorFile,vendor[i].zip);
  568. getline(vendorFile,vendor[i].phone);
  569. getline(vendorFile,vendor[i].fax);
  570. }
  571. //vendorFile.close();
  572. cout << "\t\tRecent vendor entries:" << endl << endl;
  573. for (i = 0;i < 1000;i++)
  574. {
  575. if(vendor[i].VID.empty())
  576. {
  577. maxRecord = i;
  578. i = 1000;
  579. }
  580. else
  581. {
  582. cout << "\t\t" << vendor[i].VID << "\t\t"
  583. << vendor[i].coName << endl;
  584. }
  585. }
  586. cout << endl << "\t\tMake a note of Vendor ID before proceding. " << endl << endl << "\t\t";
  587. system("PAUSE");
  588. while(vendorDisplayContinue=='Y')
  589. {
  590. system ("CLS");
  591. makeLine(65);
  592. cout << endl;
  593. cout << "\t\tEnter Vendor ID of record to display or \"9999\" to quit: " << endl << endl;
  594. makeLine(65);
  595. cout << endl << endl << "\t\t";
  596. getline(cin,searchVID);
  597. if(searchVID=="9999")
  598. {
  599. return 'X';
  600. }
  601. for(i=0;i<1000;i++)
  602. {
  603. if(vendor[i].VID==searchVID)
  604. {
  605. foundItem = i;
  606. i = 1000;
  607. }
  608. }
  609. system ("CLS");
  610. makeLine(65);
  611. cout << endl << endl;
  612. cout << "\t\tV.I.D. : " << vendor[founditem].VID << endl;
  613. cout << "\t\tCo Name: " << vendor[founditem].coName << endl;
  614. cout << "\t\tName : " << vendor[founditem].contactName << endl;
  615. cout << "\t\tAdd1 : " << vendor[founditem].address1 << endl;
  616. cout << "\t\tAdd2 : " << vendor[founditem].address2 << endl;
  617. cout << "\t\tCity : " << vendor[founditem].city << endl;
  618. cout << "\t\tState : " << vendor[founditem].state << endl;
  619. cout << "\t\tzip : " << vendor[founditem].zip << endl;
  620. cout << "\t\tphone : " << vendor[founditem].phone << endl;
  621. cout << "\t\tfax : " << vendor[founditem].fax << endl;
  622. cout << endl;
  623. makeLine(65);
  624. cout << endl << "\t\tDisplay a different record? (y/n) ";
  625. cin >> vendorDisplayContinue;
  626. } // end of Display Vendor WHILE loop
  627.  
  628. newVendorFile.close();
  629. return 'X';
  630. }
  631.  
  632. /////////////////////////////////Update Product Data///////////////////////
  633. char updateProduct(productType drink[])
  634. {
  635. // declare variables
  636. char productUpdateContinue = 'Y';
  637. string spacer;
  638. string searchSKU;
  639. string tempString;
  640. int foundIndex;
  641.  
  642. // define input files
  643. ifstream productFile;
  644. ofstream newProductFile;
  645. productFile.open("productData.txt");
  646. if (!productFile) //test for presence of productFile
  647. {
  648. cout << "\t\tUnable to open product DATA file." << endl;
  649. cout << "\t\tPlease contact developer." << endl;
  650. cout << "\t\tThis program will end." << endl;
  651. return 'X';
  652. }
  653. system ("CLS");
  654. for (i = 0;i < 1000;i++)
  655. {
  656. getline(productFile,drink[i].brand);
  657. getline(productFile,drink[i].flavor);
  658. getline(productFile,drink[i].descript);
  659. getline(productFile,drink[i].size);
  660. getline(productFile,drink[i].SKU);
  661. productFile >> drink[i].deposit;
  662. getline(productFile,spacer);
  663. }
  664. productFile.close();
  665. while(productUpdateContinue=='Y')
  666. {
  667. makeLine(65);
  668. cout << endl;
  669. cout << "\t\tEnter SKU of product to update, " << endl;
  670. cout << "\t\tor, to abandon ALL changes and return" << endl;
  671. cout << "\t\tto main menu, enter 999." << endl;
  672. cout << endl;
  673. makeLine(65);
  674. cout << endl << endl << endl << "\t\tSKU: " ;
  675. cin >> searchSKU;
  676.  
  677. if(searchSKU=="999")
  678. {
  679. return 'X';
  680. }
  681. for (i = 0; i < 1000;i++)
  682. {
  683. if(drink[i].SKU == searchSKU)
  684. {
  685. foundIndex = i;
  686. cout << endl << "\t\tRecord found for " << searchSKU << flush << endl;
  687. i = 1000;
  688. break;
  689. }
  690. if(drink[i].SKU.empty())
  691. {
  692. i = 1000;
  693. cout << endl << "\t\tSKU not Found. Try Again." << endl;
  694. continue;
  695. }
  696. }
  697. char action = 'n';
  698. makeLine(65);
  699. cout << endl << endl;
  700. cout << "\t\t1. Brand name : " << drink[foundindex].brand << endl;
  701. cout << "\t\t2. Flavor : " << drink[foundindex].flavor<< endl;
  702. cout << "\t\t3. Description : " << drink[foundindex].descript<< endl;
  703. cout << "\t\t4. Size : " << drink[foundindex].size<< endl;
  704. cout << "\t\t5. SKU : " << drink[foundindex].SKU<< endl;
  705. cout << "\t\t6. Deposit AMT : " << drink[foundindex].deposit<< endl;
  706. cout << endl << endl;
  707. makeLine(65);
  708. cout << endl << "\t\tEnter line number (1-6) to edit," << endl;
  709. cout << "Q to quit, or K to delete entire product: ";
  710. cin >> action ;
  711. if(action=='q' || action=='Q')
  712. {
  713. productUpdateContinue='N';
  714. continue;
  715. }
  716. if(action=='k' || action == 'K')
  717. {
  718. char confirm;
  719. cout << "\t\tAre you SURE? Deletion will be permanent. (y/n) ";
  720. cin >> confirm;
  721. if (confirm=='Y' || confirm == 'y')
  722. {
  723. drink[foundindex].SKU = "DELETED";
  724. }
  725. }
  726. if(action=='1')
  727. {
  728. cout << endl << "\t\tEnter new brand for SKU: " << drink[foundindex].SKU << flush << endl;
  729. cin.ignore(256,'\n');
  730. getline(cin,tempString);
  731. drink[foundindex].brand = tempString;
  732. }
  733. if(action=='2')
  734. {
  735. cout << endl << "\t\tEnter new flavor for SKU:" << drink[foundindex].SKU << endl;
  736. cin.ignore(256,'\n');
  737. getline(cin,tempString);
  738. drink[foundindex].flavor = tempString;
  739. }
  740. if(action=='3')
  741. {
  742. cout << endl << "\t\tEnter new description for SKU:" << drink[foundindex].SKU << endl;
  743. cin.ignore(256,'\n');
  744. getline(cin,tempString);
  745. drink[foundindex].descript=tempString;
  746. }
  747. if(action=='4')
  748. {
  749. cout << endl << "\t\tEnter new size for SKU:" << drink[foundindex].SKU << endl;
  750. cin.ignore(256,'\n');
  751. getline(cin,tempString);
  752. drink[foundindex].size=tempString;
  753. }
  754. if(action=='5')
  755. {
  756. cout << endl << "\t\tEnter new SKU to replace SKU:" << drink[foundindex].SKU << endl;
  757. cin.ignore(256,'\n');
  758. getline(cin,tempString);
  759. drink[foundindex].SKU=tempString;
  760. }
  761. if(action=='6')
  762. {
  763. cout << endl << "\t\tEnter new deposit amount for SKU:" << drink[foundindex].SKU << endl;
  764. cin >> drink[foundindex].deposit;
  765. }
  766. char closeSave = 'n';
  767. cout << endl << "\t\tSave changes to file (y) or abandon changes (n)?";
  768. cin >> closeSave;
  769. if(closeSave == 'y' || closeSave == 'Y')
  770. {
  771. cout << "\t\tAre you sure? Changes will be final. (y/n)";
  772. cin >> closeSave;
  773. if(closeSave == 'y' || closeSave == 'Y')
  774. {
  775. newProductFile.open("productData.txt");
  776. for(i=0;i<1000;i++)
  777. {
  778. if(drink[i].SKU.empty())
  779. {
  780. i = 1000;
  781. newProductFile << endl << "\t\tSKU not Found. Try Again." << endl;
  782. continue;
  783. }
  784. newProductFile << drink[i].brand << endl
  785. << drink[i].flavor << endl
  786. << drink[i].descript << endl
  787. << drink[i].size << endl
  788. << drink[i].SKU<< endl
  789. << drink[i].deposit << endl;
  790. }
  791. newProductFile.close();
  792. }
  793. }
  794. }
  795. // end of while loop
  796.  
  797. return 'X';
  798. }
  799. //////////////////////////// display product data ////////////////////////////
  800. char displayProduct(productType drink[])
  801. {
  802. // declare variables
  803. char productDisplayContinue = 'Y';
  804. string spacer;
  805. string searchSKU;
  806. string tempString;
  807. int foundIndex;
  808.  
  809. // define input files
  810. ifstream productFile;
  811. ofstream newProductFile;
  812. productFile.open("productData.txt");
  813. if (!productFile) //test for presence of productFile
  814. {
  815. cout << "\t\tUnable to open product DATA file." << endl;
  816. cout << "\t\tPlease contact developer." << endl;
  817. cout << "\t\tThis program will end." << endl;
  818. return 'X';
  819. }
  820. system ("CLS");
  821. for (i = 0;i < 1000;i++)
  822. {
  823. getline(productFile,drink[i].brand);
  824. getline(productFile,drink[i].flavor);
  825. getline(productFile,drink[i].descript);
  826. getline(productFile,drink[i].size);
  827. getline(productFile,drink[i].SKU);
  828. productFile >> drink[i].deposit;
  829. getline(productFile,spacer);
  830. }
  831. productFile.close();
  832. while(productDisplayContinue=='Y')
  833. {
  834. makeLine(65);
  835. cout << endl;
  836. cout << "\t\tEnter SKU of product to display, " << endl;
  837. cout << "\t\tor, to quit, enter 999." << endl;
  838. cout << endl;
  839. makeLine(65);
  840. cout << endl << endl << endl << "\t\tSKU: " ;
  841. cin >> searchSKU;
  842.  
  843. if(searchSKU=="999")
  844. {
  845. return 'X';
  846. }
  847. for (i = 0; i < 1000;i++)
  848. {
  849. if(drink[i].SKU.empty())
  850. {
  851. i = 1000;
  852. cout << endl << "\t\tSKU not Found. Try Again." << endl;
  853. continue;
  854. }
  855. if(drink[i].SKU == searchSKU)
  856. {
  857. foundIndex = i;
  858. i = 1000;
  859. }
  860. }
  861. char action = 'n';
  862. makeLine(65);
  863. cout << endl << endl;
  864. cout << "\t\t1. Brand name : " << drink[foundindex].brand << endl;
  865. cout << "\t\t2. Flavor : " << drink[foundindex].flavor<< endl;
  866. cout << "\t\t3. Description : " << drink[foundindex].descript<< endl;
  867. cout << "\t\t4. Size : " << drink[foundindex].size<< endl;
  868. cout << "\t\t5. SKU : " << drink[foundindex].SKU<< endl << flush;
  869. cout << "\t\t6. Deposit AMT : " << drink[foundindex].deposit<< endl;
  870. cout << endl << endl;
  871. makeLine(65);
  872.  
  873. cout << endl << "\t\tWould you like to display another product? (y/n) ";
  874. cin >> productDisplayContinue;
  875. if(productDisplayContinue=='n' || productDisplayContinue=='N')
  876. {
  877. productDisplayContinue = 'N';
  878. }
  879. }
  880. return 'R';
  881. }
  882.  
  883.  
  884.  
  885. [B]My programming skill's are not the best, so bear with me.
  886.  
  887. Here's my section so far
  888. i list the functions
  889. [/B]
  890. void reportline;
  891.  
  892. int findsku;
  893. string itm = 0;
  894. int index;
  895. int found;
  896. found = false;
  897. int i;
  898. cout << "Please enter in sku or type 0 for all skus";
  899. cin >> findsku;
  900.  
  901. now do I use fstream here or can I just use
  902.  
  903. for (findsku=0; findsku<nextopen;findsku++
  904. {
  905. if(strcmp(invenType[inventoryline[index].sku,itm)= =0);
  906. {found=1;
  907. break;
  908. }
  909. }
  910. break;
  911.  
  912. if inventoryLine.quantity <= 5;
  913. cout << findsku << quantity << endl;
  914. }
  915.  
  916. InventoryLine [1000]
  917. int maxRecord;
  918. #include fstream;
  919. open inventoryType.inventoryLine;
  920.  
  921. for (i=0; i <1000, i++)
  922. {
  923. getline(inventFile.inventoryLine[i].sku;
  924. getline(inventFile.inventoryLine[i].quantity;
  925. if inventoryLine[i].sku== " ";
  926. {
  927. maxRecord= i;
  928. i = 1000;
  929. }
Please any help would be recommended, I get so frustrated and lost on this stuff.
Last edited by ~s.o.s~; Jun 3rd, 2007 at 3:29 pm. Reason: Added code tags, learn to use them.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Need help C++ inventory project

 
0
  #2
Jun 3rd, 2007
What you should have done was pressed compile and run at every ten lines of code instead of right at the end.

  1. Compiler: Default compiler
  2. Executing g++.exe...
  3. g++.exe "C:\Documents and Settings\user\My Documents\test.cpp" -o "C:\Documents and Settings\user\My Documents\test.exe" -pg -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lgmon -pg -g3
  4. C:\Documents and Settings\user\My Documents\test.cpp: In function `char makeMenu()':
  5. C:\Documents and Settings\user\My Documents\test.cpp:175: error: `size' undeclared (first use this function)
  6. C:\Documents and Settings\user\My Documents\test.cpp:175: error: (Each undeclared identifier is reported only once for each function it appears in.)
  7. C:\Documents and Settings\user\My Documents\test.cpp:176: error: `errno_t' undeclared (first use this function)
  8. C:\Documents and Settings\user\My Documents\test.cpp:176: error: expected `;' before "err"
  9. C:\Documents and Settings\user\My Documents\test.cpp:179: error: `err' undeclared (first use this function)
  10. C:\Documents and Settings\user\My Documents\test.cpp:179: error: `buf' undeclared (first use this function)
  11. C:\Documents and Settings\user\My Documents\test.cpp:179: error: `_wctime_s' undeclared (first use this function)
  12. C:\Documents and Settings\user\My Documents\test.cpp: In function `char updateMenu()':
  13. C:\Documents and Settings\user\My Documents\test.cpp:228: error: `size' undeclared (first use this function)
  14. C:\Documents and Settings\user\My Documents\test.cpp:229: error: `errno_t' undeclared (first use this function)
  15. C:\Documents and Settings\user\My Documents\test.cpp:229: error: expected `;' before "err"
  16. C:\Documents and Settings\user\My Documents\test.cpp:232: error: `err' undeclared (first use this function)
  17. C:\Documents and Settings\user\My Documents\test.cpp:232: error: `buf' undeclared (first use this function)
  18. C:\Documents and Settings\user\My Documents\test.cpp:232: error: `_wctime_s' undeclared (first use this function)
  19. C:\Documents and Settings\user\My Documents\test.cpp: In function `char updateVendor(companyType*)':
  20. C:\Documents and Settings\user\My Documents\test.cpp:356: error: `choicenum' undeclared (first use this function)
  21. C:\Documents and Settings\user\My Documents\test.cpp:375: error: `selectitem' undeclared (first use this function)
  22. C:\Documents and Settings\user\My Documents\test.cpp:390: error: `founditem' undeclared (first use this function)
  23. C:\Documents and Settings\user\My Documents\test.cpp: In function `char displayVendor(companyType*)':
  24. C:\Documents and Settings\user\My Documents\test.cpp:602: error: `founditem' undeclared (first use this function)
  25. C:\Documents and Settings\user\My Documents\test.cpp: In function `char updateProduct(productType*)':
  26. C:\Documents and Settings\user\My Documents\test.cpp:690: error: `foundindex' undeclared (first use this function)
  27. C:\Documents and Settings\user\My Documents\test.cpp: In function `char displayProduct(productType*)':
  28. C:\Documents and Settings\user\My Documents\test.cpp:854: error: `foundindex' undeclared (first use this function)
  29. Execution terminated
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,580
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 709
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Need help C++ inventory project

 
0
  #3
Jun 3rd, 2007
It's a good think you posted your code before it passed 1000 lines, otherwise we might complain that it was too long...
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,342
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1460
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Need help C++ inventory project

 
0
  #4
Jun 3rd, 2007
Here is another instance I have seen today where someone posts the same problem on multiple programming web sites. That deminishes the probability you will get the answers you want and increases the probablility that you will get the same or conflicting answers.

Also, you posted the description of the program but no mention of the problems you are having. We can not help you very much if we have to read your mind.
Last edited by Ancient Dragon; Jun 3rd, 2007 at 7:57 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2
Reputation: ssaurabh has a little shameless behaviour in the past 
Solved Threads: 0
ssaurabh ssaurabh is offline Offline
Newbie Poster

Re: Need help C++ inventory project

 
-1
  #5
Jul 28th, 2008
have u completed this project??
Please, I m in urgent need of this project
Plz mail me at <snipped email>
Last edited by Ancient Dragon; Jul 28th, 2008 at 9:12 am. Reason: snipped email
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC