Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 27.52 KB | None | 0 0
  1.  
  2. See how your visitors are really using your website.
  3. TRY IT FOR FREE
  4. HIDE AD • AD VIA BUYSELLADS
  5. PASTEBINnew pastePRO    API tools faq deals
  6. search...
  7.  
  8.  
  9. Guest User
  10. -
  11. Public Pastes
  12. Untitled
  13. 0 sec ago
  14. Untitled
  15. 2 sec ago
  16. Untitled
  17. 4 sec ago
  18. Untitled
  19. 5 sec ago
  20. wwe
  21. JavaScript | 8 sec ago
  22. Untitled
  23. 15 sec ago
  24. Weak
  25. 19 sec ago
  26. Untitled
  27. 21 sec ago
  28. daily pastebin  goal
  29. 52%
  30. help support pastebin
  31.  
  32. SHARE
  33. TWEET
  34.  
  35.  Untitled
  36.  A GUEST   MAR 22ND, 2019   1   IN 29 DAYS
  37.  
  38. Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  39. rawdownloadcloneembedreportprint text 13.10 KB
  40. Pseudo code for Programming Project 5 – Due 3/21/2019
  41.  
  42. This project involves completing Programming Exercise 12 at the end of chapter 10.
  43.  
  44. A.   Add an include for the following bookType header :
  45.  
  46. class bookType
  47. {
  48. public:
  49.     void setBookInfo(string title, string ISBN,
  50.                      string Publisher, int PublishYear,
  51.                      string auth[], double cost, int copies,
  52.                      int noAuthors);
  53.     void setBookTitle(string s);
  54.     void setBookISBN(string s);
  55.     void setBookPrice(double cost);
  56.     void setCopiesInStock(int noOfCopies);
  57.  
  58.     void printInfo() const;
  59.  
  60.     bool isISBN(string s) const;
  61.     bool isTitle(string s) const;
  62.     bool isAuthor(string s) const;
  63.  
  64.     void getBookTitle(string& s) const;
  65.     void getBookISBN(string& s) const;
  66.     double getBookPrice() const;
  67.  
  68.     bool isInStock() const;
  69.     void makeSale();
  70.  
  71.     void printBookPrice() const;
  72.     void printbookTitle() const;
  73.     void printbookTitleAndISBN() const;
  74.     void showQuantityInStock() const;
  75.     void updateQuantity(int addBooks);
  76.  
  77.     bookType();
  78.  
  79. private:
  80.     string bookTitle;
  81.     string bookISBN;
  82.     string bookPublisher;
  83.     int bookPublishYear;
  84.     string authors[4];
  85.  
  86.     double price;
  87.     int quantity;
  88.  
  89.     int noOfAuthors;
  90. };
  91.  
  92. B.  Declare the following prototypes :
  93.  
  94. void getBookData(bookType books[], int& noOfBooks);
  95. void printBookData(bookType books[], int noOfBooks);
  96. void searchBookData(bookType books[], int bookCount);
  97. void searchBookDataByISBN(bookType books[], int bookCount, string ISBN,
  98.                          int& loc);
  99. void searchBookDataByTitle(bookType books[], int bookCount, string title,
  100.                             int& loc);
  101. void updateCopiesInStock(bookType books[], int bookCount);
  102.  
  103. plus two more :
  104. 1.  One to show the main menu
  105. 2.  One to show the submenu
  106.  
  107. C.  In the mainline :
  108.           Declare an array to store up to 100 books.  The array will be of the type
  109.           bookType.
  110.  
  111.           Declare an int variable to store the number of books in the array.
  112.  
  113.           Declare an int variable to store the user’s choice when they use the menu
  114.  
  115.           Set manipulators so the prices are outputted with 2 decimal positions.
  116.  
  117.           Call the getBookData function
  118.           Call the showMenu function
  119.          
  120.           Accept the user’s choice
  121.  
  122.           While user’s choice not equal 9:
  123.              Use a switch structure to interrogate the value of choice.  There are 5 cases
  124.              which correspond to the menu and the default case:
  125.  
  126.              For case 1:  Write the code to loop through the books array.  For each
  127.                                 element in the array, invoke the class member function
  128.                                 printbookTitle().
  129.  
  130.  
  131.              For case 2:  Write the code to loop through the books array.  For each
  132.                                 element in the array, invoke the class member function
  133.                                 printbookTitleAndISBN().
  134.  
  135.              For cases 3, 4 and 5:  Call the appropriate function
  136.  
  137.              Call the showMenu function
  138.  
  139.              Accept the user’s choice
  140.  
  141.          End program.
  142. D.  After the mainline :
  143.           Define the non-class member functions called within the mainline.
  144. 1.  getBookData function :  
  145.  
  146. void getBookData(bookType books[], int& noOfBooks)
  147. {
  148.     string title;
  149.     string ISBN;
  150.     string Publisher;
  151.     int PublishYear;
  152.     string auth[4];
  153.     double cost;
  154.     int copies;
  155.     int authorCount;
  156.  
  157.     int i, j;
  158.  
  159. -   Declare an input file called infile.
  160. -   Open the input file and verify it is opened successfully.  If not, terminate
  161.      the program.
  162.     char ch;
  163.     infile >> noOfBooks;
  164.     infile.get(ch);
  165.  
  166.     for (i = 0; i < noOfBooks; i++)
  167.     {
  168.         getline(infile, title);
  169.         getline(infile,ISBN);
  170.         getline(infile,Publisher);
  171.         infile >> PublishYear >> cost >> copies >> authorCount;
  172.         infile.get(ch);
  173.  
  174.         for (j = 0; j < authorCount; j++)
  175.             getline(infile, auth[j]);
  176.  
  177.         books[i].setBookInfo(title, ISBN, Publisher,
  178.                              PublishYear, auth, cost, copies,
  179.                              authorCount);
  180.     }
  181. }
  182.  
  183.  
  184.      2. searchBookData function :  
  185.  
  186. void searchBookData(bookType books[], int bookCount)
  187. {
  188.     int choice;
  189.     char ch;
  190.  
  191.     int loc;
  192.  
  193.     string str;
  194.  
  195.     Call the submenu function
  196.  
  197.     Accept user’s choice
  198.  
  199.               Use a switch structure to interrogate the value of choice.  There are 3 cases
  200.               which correspond to the menu and the default case:
  201.  
  202.               For case 1:  Prompt and accept ISBN
  203.                                  Call searchBookDataByISBN
  204.                                  If loc not equal to -1 state that the store sells the book.
  205.                                  Otherwise, state the store does not.
  206.  
  207.               For case 2:  Prompt and accept Book Title
  208.                                  Call searchBookDataByTitle
  209.                                  If loc not equal to -1 state that the store sells the book.
  210.                                  Otherwise, state the store does not.
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.      3. searchBookDataByISBN function :  
  223.  
  224.          This is the code to locate the index of the books array where the ISBN is found :
  225.  
  226. {
  227.     int i;
  228.     loc = -1;
  229.  
  230.     for (i = 0; i < bookCount; i++)
  231.         if (books[i].isISBN(ISBN))
  232.         {
  233.             loc = i;
  234.             break;
  235.         }
  236. }
  237.  
  238. 4. searchBookDataByTile function :  Model code after searchBookDataByISBN
  239.                                                            function
  240.  
  241. 5.  updateCopiesInStock function
  242. {
  243.     int choice;
  244.  
  245.     int loc;
  246.  
  247.     int count;
  248.     char ch;
  249.  
  250.     string str;
  251.  
  252.     Call the submenu function
  253.  
  254.     Accept user’s choice
  255.  
  256.               Use a switch structure to interrogate the value of choice.  There are 3 cases
  257.               which correspond to the menu and the default case:
  258.  
  259.               For case 1:  Prompt and accept ISBN
  260.                                  Call searchBookDataByISBN
  261.                                  If loc not equal to -1
  262.                                         prompt and accept number of books
  263.                                         call the class member function updateQuantitiy.
  264.                                  Otherwise, state the store does not sell book.
  265.  
  266.  
  267.            
  268.  
  269.               For case 2:  Prompt and accept Book Title
  270.                                  Call searchBookDataByTitle
  271.                                  If loc not equal to -1
  272.                                         prompt and accept number of books
  273.                                         call the class member function updateQuantitiy.
  274.                                  Otherwise, state the store does not sell book.
  275.  
  276.  
  277.      6.  printBookData function :  
  278.  
  279.            Write the code to loop through the books array.  For each element in the
  280.            array, invoke the class member function printInfo().  See the sample execution
  281.            below for the output
  282.  
  283.      7. showMenu function :  
  284.  
  285. Outputs :
  286.  
  287. Welcome to Rock's Book Store
  288. To make a selection enter the number and press enter
  289. 1: Print a list of books
  290. 2: Print a list of books and ISBN numbers
  291. 3: To see if a book in store
  292. 4: To update the number of copies of a book
  293. 5: To print books data
  294. 9: Exit the program.
  295.  
  296.  
  297.  
  298. 8.  subMenu function :  
  299.  
  300. Outputs :
  301.  
  302. Enter
  303. 1: To search the book by ISBN
  304. 2: To search the book by title
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314. E.  Implementation File :
  315.          Define the class member functions :
  316. void bookType::setBookInfo(string title, string ISBN,
  317.                     string Publisher, int PublishYear,
  318.                     string auth[], double cost, int copies,
  319.                     int authorCount)
  320. {
  321.   Set all the private class members to parmeters.  Note that there can be up to
  322.   4 authors per book.
  323. }
  324.  
  325. void bookType::setBookTitle(string s)
  326. {
  327.    bookTitle =  s;
  328. }
  329.  
  330. setBookISBN : Follow setBookTitle function definition
  331.  
  332. setBookPrice : Follow setBookTitle function definition
  333.  
  334. setCopiesInStock : Follow setBookTitle function definition
  335.  
  336. printInfo: Output the contents of the private variables per execution
  337.                example.  For instance :
  338.  
  339. Title: C++Programing: From Problem Analysis to Program Design
  340. ISBN: 5-17-525281-3
  341. Publisher: ABC
  342. Year of Publication: 2000
  343. Number of Authors: 1
  344. Authors: Malik, D.S.;
  345. Price: 52.5
  346. Quantities in stock: 20
  347.  
  348.  
  349. bool bookType::isISBN(string s) const
  350. {
  351.    return (bookISBN == s);
  352. }
  353.  
  354. isTitle Follow bookType::isISBN function definition
  355.  
  356.  
  357.  
  358.  
  359. bool bookType::isAuthor(string s) const
  360. {
  361.    bool found = false;
  362.    int i;
  363.  
  364.    for (i = 0; i < noOfAuthors; i++)
  365.        if (authors[i] == s)
  366.        {
  367.            found = true;
  368.            break;
  369.        }
  370.  
  371.    return found;
  372. }
  373.  
  374. void bookType::getBookTitle(string& s) const
  375. {
  376.    s = bookTitle;
  377. }
  378.  
  379. getBookISBN Follow getBookTitle function definition
  380.  
  381. double bookType::getBookPrice() const
  382. {
  383.    return price;
  384. }
  385.  
  386. bool bookType::isInStock() const
  387. {
  388.    return (quantity > 0);
  389. }
  390.  
  391. void bookType::makeSale()
  392. {
  393.    quantity--;
  394. }
  395.  
  396. void bookType::printBookPrice() const
  397. {
  398.    cout << "Price = " << price << endl;
  399. }
  400.  
  401. printbookTitle Follow printBookPrice function definition
  402.  
  403. printbookTitleAndISBN Follow printBookPrice function definition
  404.  
  405.  
  406. showQuantityInStock Follow printBookPrice function definition
  407.  
  408. void bookType::updateQuantity(int addBooks)
  409. {
  410.    quantity = quantity + addBooks;
  411. }
  412.  
  413. bookType::bookType()
  414. {
  415.    int i;
  416.  
  417.    bookTitle = "";
  418.    bookISBN = "";
  419.    bookPublisher = "";
  420.  
  421.    bookPublishYear = 1900;
  422.  
  423.    noOfAuthors = 0;
  424.  
  425.    for (i = 0; i < 4; i++)
  426.        authors[i] = "";
  427.  
  428.    price = 0;
  429.    quantity = 0;
  430. }
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.                  (See next page for a sample execution)
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447. F.  Sample execution :
  448.  
  449. Welcome to Rock's Book Store
  450. To make a selection enter the number and press enter
  451. 1: Print a list of books
  452. 2: Print a list of books and ISBN numbers
  453. 3: To see if a book in store
  454. 4: To update the number of copies of a book
  455. 5: To print books data
  456. 9: Exit the program.
  457.  
  458. 2
  459.  
  460. Title: C++Programing: From Problem Analysis to Program Design;  ISBN: 5-17-525281-3
  461. Title: Fuzzy Discrete Structures;  ISBN: 3-7908-1335-4
  462. Title: Fuzzy Mathematic in Medicine;  ISBN: 3-7908-1325-7
  463. Title: Harry John and The Magician;  ISBN: 0-239-23635-0
  464. Title: Dynamic InterWeb Programming;  ISBN: 22-99521-453-1
  465.  
  466. Welcome to Rock's Book Store
  467. To make a selection enter the number and press enter
  468. 1: Print a list of books
  469. 2: Print a list of books and ISBN numbers
  470. 3: To see if a book in store
  471. 4: To update the number of copies of a book
  472. 5: To print books data
  473. 9: Exit the program.
  474.  
  475. 3
  476.  
  477. Enter
  478. 1: To search the book by ISBN
  479. 2: To search the book by title
  480.  
  481. 1
  482.  
  483. Enter the ISBN of the book.
  484.  
  485. 0-239-23635-0
  486.  
  487. The store sells this book.
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496. Welcome to Rock's Book Store
  497. To make a selection enter the number and press enter
  498. 1: Print a list of books
  499. 2: Print a list of books and ISBN numbers
  500. 3: To see if a book in store
  501. 4: To update the number of copies of a book
  502. 5: To print books data
  503. 9: Exit the program.
  504.  
  505. 4
  506.  
  507. Enter
  508.  
  509. 1: To search the book by ISBN
  510. 2: To search the book by title
  511.  
  512. 2
  513.  
  514. Enter the title of the book.
  515.  
  516. Dynamic InterWeb Programming
  517.  
  518. Enter the number of books  4
  519.  
  520. Welcome to Rock's Book Store
  521. To make a selection enter the number and press enter
  522. 1: Print a list of books
  523. 2: Print a list of books and ISBN numbers
  524. 3: To see if a book in store
  525. 4: To update the number of copies of a book
  526. 5: To print books data
  527. 9: Exit the program.
  528. 5
  529. Title: C++Programing: From Problem Analysis to Program Design
  530. ISBN: 5-17-525281-3
  531. Publisher: ABC
  532. Year of Publication: 2000
  533. Number of Authors: 1
  534. Authors: Malik, D.S.;
  535. Price: 52.5
  536. Quantities in stock: 20
  537.  
  538. ---------------------------------
  539. Title: Fuzzy Discrete Structures
  540. ISBN: 3-7908-1335-4
  541. Publisher: Physica-Verlag
  542. Year of Publication: 2000
  543. Number of Authors: 2
  544. Authors: Malik, Davender; Mordeson, John;
  545. Price: 89
  546. Quantities in stock: 10
  547.  
  548. ---------------------------------
  549. Title: Fuzzy Mathematic in Medicine
  550. ISBN: 3-7908-1325-7
  551. Publisher: Physica-Verlag
  552. Year of Publication: 2000
  553. Number of Authors: 3
  554. Authors: Mordeson, John; Malik, Davender; Cheng, Shih-Chung;
  555. Price: 89
  556. Quantities in stock: 10
  557.  
  558. ---------------------------------
  559. Title: Harry John and The Magician
  560. ISBN: 0-239-23635-0
  561. Publisher: McArthur A. Devine Books
  562. Year of Publication: 1999
  563. Number of Authors: 3
  564. Authors: Goof, Goofy; Pluto, Peter; Head, Mark;
  565. Price: 19.95
  566. Quantities in stock: 10
  567.  
  568. ---------------------------------
  569. Title: Dynamic InterWeb Programming
  570. ISBN: 22-99521-453-1
  571. Publisher: GNet
  572. Year of Publication: 1998
  573. Number of Authors: 1
  574. Authors: Goof, Goofy;
  575. Price: 39.99
  576. Quantities in stock: 29
  577.  
  578. ---------------------------------
  579. Welcome to Rock's Book Store
  580. To make a selection enter the number and press enter
  581. 1: Print a list of books
  582. 2: Print a list of books and ISBN numbers
  583. 3: To see if a book in store
  584. 4: To update the number of copies of a book
  585. 5: To print books data
  586. 9: Exit the program.
  587.  
  588. 9
  589.  
  590. --------------------------------
  591. Process exited with return value 0
  592. Press any key to continue . . .
  593. RAW Paste Data
  594. Pseudo code for Programming Project 5 – Due 3/21/2019
  595.  
  596. This project involves completing Programming Exercise 12 at the end of chapter 10.
  597.  
  598. A.   Add an include for the following bookType header :
  599.  
  600. class bookType
  601. {
  602. public:
  603.     void setBookInfo(string title, string ISBN,
  604.                      string Publisher, int PublishYear,
  605.                      string auth[], double cost, int copies,
  606.                      int noAuthors);
  607.     void setBookTitle(string s);
  608.     void setBookISBN(string s);
  609.     void setBookPrice(double cost);
  610.     void setCopiesInStock(int noOfCopies);
  611.  
  612.     void printInfo() const;
  613.  
  614.     bool isISBN(string s) const;
  615.     bool isTitle(string s) const;
  616.     bool isAuthor(string s) const;
  617.  
  618.     void getBookTitle(string& s) const;
  619.     void getBookISBN(string& s) const;
  620.     double getBookPrice() const;
  621.  
  622.     bool isInStock() const;
  623.     void makeSale();
  624.  
  625.     void printBookPrice() const;
  626.     void printbookTitle() const;
  627.     void printbookTitleAndISBN() const;
  628.     void showQuantityInStock() const;
  629.     void updateQuantity(int addBooks);
  630.  
  631.     bookType();
  632.  
  633. private:
  634.     string bookTitle;
  635.     string bookISBN;
  636.     string bookPublisher;
  637.     int bookPublishYear;
  638.     string authors[4];
  639.  
  640.     double price;
  641.     int quantity;
  642.  
  643.     int noOfAuthors;
  644. };
  645.  
  646. B.  Declare the following prototypes :
  647.  
  648. void getBookData(bookType books[], int& noOfBooks);
  649. void printBookData(bookType books[], int noOfBooks);
  650. void searchBookData(bookType books[], int bookCount);
  651. void searchBookDataByISBN(bookType books[], int bookCount, string ISBN,
  652.                          int& loc);
  653. void searchBookDataByTitle(bookType books[], int bookCount, string title,
  654.                             int& loc);
  655. void updateCopiesInStock(bookType books[], int bookCount);
  656.  
  657. plus two more :
  658. 1One to show the main menu
  659. 2One to show the submenu
  660.  
  661. C.  In the mainline :
  662.           Declare an array to store up to 100 books.  The array will be of the type
  663.           bookType.
  664.  
  665.           Declare an int variable to store the number of books in the array.
  666.  
  667.           Declare an int variable to store the user’s choice when they use the menu
  668.  
  669.           Set manipulators so the prices are outputted with 2 decimal positions.
  670.  
  671.           Call the getBookData function
  672.           Call the showMenu function
  673.          
  674.           Accept the user’s choice
  675.  
  676.           While user’s choice not equal 9:
  677.              Use a switch structure to interrogate the value of choice.  There are 5 cases
  678.              which correspond to the menu and the default case:
  679.  
  680.              For case 1:  Write the code to loop through the books array.  For each
  681.                                 element in the array, invoke the class member function
  682.                                 printbookTitle().
  683.  
  684.  
  685.              For case 2:  Write the code to loop through the books array.  For each
  686.                                 element in the array, invoke the class member function
  687.                                 printbookTitleAndISBN().
  688.  
  689.              For cases 3, 4 and 5:  Call the appropriate function
  690.  
  691.              Call the showMenu function
  692.  
  693.              Accept the user’s choice
  694.  
  695.          End program.
  696. DAfter the mainline :
  697.           Define the non-class member functions called within the mainline.
  698. 1getBookData function :  
  699.  
  700. void getBookData(bookType books[], int& noOfBooks)
  701. {
  702.     string title;
  703.     string ISBN;
  704.     string Publisher;
  705.     int PublishYear;
  706.     string auth[4];
  707.     double cost;
  708.     int copies;
  709.     int authorCount;
  710.  
  711.     int i, j;
  712.  
  713. -   Declare an input file called infile.
  714. -   Open the input file and verify it is opened successfully.  If not, terminate
  715.      the program.
  716.     char ch;
  717.     infile >> noOfBooks;
  718.     infile.get(ch);
  719.  
  720.     for (i = 0; i < noOfBooks; i++)
  721.     {
  722.         getline(infile, title);
  723.         getline(infile,ISBN);
  724.         getline(infile,Publisher);
  725.         infile >> PublishYear >> cost >> copies >> authorCount;
  726.         infile.get(ch);
  727.  
  728.         for (j = 0; j < authorCount; j++)
  729.             getline(infile, auth[j]);
  730.  
  731.         books[i].setBookInfo(title, ISBN, Publisher,
  732.                              PublishYear, auth, cost, copies,
  733.                              authorCount);
  734.     }
  735. }
  736.  
  737.  
  738.      2. searchBookData function :  
  739.  
  740. void searchBookData(bookType books[], int bookCount)
  741. {
  742.     int choice;
  743.     char ch;
  744.  
  745.     int loc;
  746.  
  747.     string str;
  748.  
  749.     Call the submenu function
  750.  
  751.     Accept user’s choice
  752.  
  753.               Use a switch structure to interrogate the value of choice.  There are 3 cases
  754.               which correspond to the menu and the default case:
  755.  
  756.               For case 1:  Prompt and accept ISBN
  757.                                  Call searchBookDataByISBN
  758.                                  If loc not equal to -1 state that the store sells the book.
  759.                                  Otherwise, state the store does not.
  760.  
  761.               For case 2:  Prompt and accept Book Title
  762.                                  Call searchBookDataByTitle
  763.                                  If loc not equal to -1 state that the store sells the book.
  764.                                  Otherwise, state the store does not.
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.      3. searchBookDataByISBN function :  
  777.  
  778.          This is the code to locate the index of the books array where the ISBN is found :
  779.  
  780. {
  781.     int i;
  782.     loc = -1;
  783.  
  784.     for (i = 0; i < bookCount; i++)
  785.         if (books[i].isISBN(ISBN))
  786.         {
  787.             loc = i;
  788.             break;
  789.         }
  790. }
  791.  
  792. 4. searchBookDataByTile function :  Model code after searchBookDataByISBN
  793.                                                            function
  794.  
  795. 5updateCopiesInStock function
  796. {
  797.     int choice;
  798.  
  799.     int loc;
  800.  
  801.     int count;
  802.     char ch;
  803.  
  804.     string str;
  805.  
  806.     Call the submenu function
  807.  
  808.     Accept user’s choice
  809.  
  810.               Use a switch structure to interrogate the value of choice.  There are 3 cases
  811.               which correspond to the menu and the default case:
  812.  
  813.               For case 1:  Prompt and accept ISBN
  814.                                  Call searchBookDataByISBN
  815.                                  If loc not equal to -1
  816.                                         prompt and accept number of books
  817.                                         call the class member function updateQuantitiy.
  818.                                  Otherwise, state the store does not sell book.
  819.  
  820.  
  821.            
  822.  
  823.               For case 2:  Prompt and accept Book Title
  824.                                  Call searchBookDataByTitle
  825.                                  If loc not equal to -1
  826.                                         prompt and accept number of books
  827.                                         call the class member function updateQuantitiy.
  828.                                  Otherwise, state the store does not sell book.
  829.  
  830.  
  831.      6.  printBookData function :  
  832.  
  833.            Write the code to loop through the books array.  For each element in the
  834.            array, invoke the class member function printInfo().  See the sample execution
  835.            below for the output
  836.  
  837.      7. showMenu function :  
  838.  
  839. Outputs :
  840.  
  841. Welcome to Rock's Book Store
  842. To make a selection enter the number and press enter
  843. 1: Print a list of books
  844. 2: Print a list of books and ISBN numbers
  845. 3: To see if a book in store
  846. 4: To update the number of copies of a book
  847. 5: To print books data
  848. 9: Exit the program.
  849.  
  850.  
  851.  
  852. 8.  subMenu function :  
  853.  
  854. Outputs :
  855.  
  856. Enter
  857. 1: To search the book by ISBN
  858. 2: To search the book by title
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868. E.  Implementation File :
  869.          Define the class member functions :
  870. void bookType::setBookInfo(string title, string ISBN,
  871.                      string Publisher, int PublishYear,
  872.                      string auth[], double cost, int copies,
  873.                      int authorCount)
  874. {
  875.   Set all the private class members to parmeters.  Note that there can be up to
  876.   4 authors per book.
  877. }
  878.  
  879. void bookType::setBookTitle(string s)
  880. {
  881.    bookTitle =  s;
  882. }
  883.  
  884. setBookISBN : Follow setBookTitle function definition
  885.  
  886. setBookPrice : Follow setBookTitle function definition
  887.  
  888. setCopiesInStock : Follow setBookTitle function definition
  889.  
  890. printInfo: Output the contents of the private variables per execution
  891.                example.  For instance :
  892.  
  893. Title: C++Programing: From Problem Analysis to Program Design
  894. ISBN: 5-17-525281-3
  895. Publisher: ABC
  896. Year of Publication: 2000
  897. Number of Authors: 1
  898. Authors: Malik, D.S.;
  899. Price: 52.5
  900. Quantities in stock: 20
  901.  
  902.  
  903. bool bookType::isISBN(string s) const
  904. {
  905.    return (bookISBN == s);
  906. }
  907.  
  908. isTitle Follow bookType::isISBN function definition
  909.  
  910.  
  911.  
  912.  
  913. bool bookType::isAuthor(string s) const
  914. {
  915.    bool found = false;
  916.    int i;
  917.  
  918.    for (i = 0; i < noOfAuthors; i++)
  919.        if (authors[i] == s)
  920.        {
  921.            found = true;
  922.            break;
  923.        }
  924.  
  925.    return found;
  926. }
  927.  
  928. void bookType::getBookTitle(string& s) const
  929. {
  930.    s = bookTitle;
  931. }
  932.  
  933. getBookISBN Follow getBookTitle function definition
  934.  
  935. double bookType::getBookPrice() const
  936. {
  937.    return price;
  938. }
  939.  
  940. bool bookType::isInStock() const
  941. {
  942.    return (quantity > 0);
  943. }
  944.  
  945. void bookType::makeSale()
  946. {
  947.    quantity--;
  948. }
  949.  
  950. void bookType::printBookPrice() const
  951. {
  952.    cout << "Price = " << price << endl;
  953. }
  954.  
  955. printbookTitle Follow printBookPrice function definition
  956.  
  957. printbookTitleAndISBN Follow printBookPrice function definition
  958.  
  959.  
  960. showQuantityInStock Follow printBookPrice function definition
  961.  
  962. void bookType::updateQuantity(int addBooks)
  963. {
  964.    quantity = quantity + addBooks;
  965. }
  966.  
  967. bookType::bookType()
  968. {
  969.    int i;
  970.  
  971.    bookTitle = "";
  972.    bookISBN = "";
  973.    bookPublisher = "";
  974.  
  975.    bookPublishYear = 1900;
  976.  
  977.    noOfAuthors = 0;
  978.  
  979.    for (i = 0; i < 4; i++)
  980.        authors[i] = "";
  981.  
  982.    price = 0;
  983.    quantity = 0;
  984. }
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.                  (See next page for a sample execution)
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001. F.  Sample execution :
  1002.  
  1003. Welcome to Rock's Book Store
  1004. To make a selection enter the number and press enter
  1005. 1: Print a list of books
  1006. 2: Print a list of books and ISBN numbers
  1007. 3: To see if a book in store
  1008. 4: To update the number of copies of a book
  1009. 5: To print books data
  1010. 9: Exit the program.
  1011.  
  1012. 2
  1013.  
  1014. Title: C++Programing: From Problem Analysis to Program Design;  ISBN: 5-17-525281-3
  1015. Title: Fuzzy Discrete Structures;  ISBN: 3-7908-1335-4
  1016. Title: Fuzzy Mathematic in Medicine;  ISBN: 3-7908-1325-7
  1017. Title: Harry John and The Magician;  ISBN: 0-239-23635-0
  1018. Title: Dynamic InterWeb Programming;  ISBN: 22-99521-453-1
  1019.  
  1020. Welcome to Rock's Book Store
  1021. To make a selection enter the number and press enter
  1022. 1: Print a list of books
  1023. 2: Print a list of books and ISBN numbers
  1024. 3: To see if a book in store
  1025. 4: To update the number of copies of a book
  1026. 5: To print books data
  1027. 9: Exit the program.
  1028.  
  1029. 3
  1030.  
  1031. Enter
  1032. 1: To search the book by ISBN
  1033. 2: To search the book by title
  1034.  
  1035. 1
  1036.  
  1037. Enter the ISBN of the book.
  1038.  
  1039. 0-239-23635-0
  1040.  
  1041. The store sells this book.
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050. Welcome to Rock's Book Store
  1051. To make a selection enter the number and press enter
  1052. 1: Print a list of books
  1053. 2: Print a list of books and ISBN numbers
  1054. 3: To see if a book in store
  1055. 4: To update the number of copies of a book
  1056. 5: To print books data
  1057. 9: Exit the program.
  1058.  
  1059. 4
  1060.  
  1061. Enter
  1062.  
  1063. 1: To search the book by ISBN
  1064. 2: To search the book by title
  1065.  
  1066. 2
  1067.  
  1068. Enter the title of the book.
  1069.  
  1070. Dynamic InterWeb Programming
  1071.  
  1072. Enter the number of books  4
  1073.  
  1074. Welcome to Rock's Book Store
  1075. To make a selection enter the number and press enter
  1076. 1: Print a list of books
  1077. 2: Print a list of books and ISBN numbers
  1078. 3: To see if a book in store
  1079. 4: To update the number of copies of a book
  1080. 5: To print books data
  1081. 9: Exit the program.
  1082. 5
  1083. Title: C++Programing: From Problem Analysis to Program Design
  1084. ISBN: 5-17-525281-3
  1085. Publisher: ABC
  1086. Year of Publication: 2000
  1087. Number of Authors: 1
  1088. Authors: Malik, D.S.;
  1089. Price: 52.5
  1090. Quantities in stock: 20
  1091.  
  1092. ---------------------------------
  1093. Title: Fuzzy Discrete Structures
  1094. ISBN: 3-7908-1335-4
  1095. Publisher: Physica-Verlag
  1096. Year of Publication: 2000
  1097. Number of Authors: 2
  1098. Authors: Malik, Davender; Mordeson, John;
  1099. Price: 89
  1100. Quantities in stock: 10
  1101.  
  1102. ---------------------------------
  1103. Title: Fuzzy Mathematic in Medicine
  1104. ISBN: 3-7908-1325-7
  1105. Publisher: Physica-Verlag
  1106. Year of Publication: 2000
  1107. Number of Authors: 3
  1108. Authors: Mordeson, John; Malik, Davender; Cheng, Shih-Chung;
  1109. Price: 89
  1110. Quantities in stock: 10
  1111.  
  1112. ---------------------------------
  1113. Title: Harry John and The Magician
  1114. ISBN: 0-239-23635-0
  1115. Publisher: McArthur A. Devine Books
  1116. Year of Publication: 1999
  1117. Number of Authors: 3
  1118. Authors: Goof, Goofy; Pluto, Peter; Head, Mark;
  1119. Price: 19.95
  1120. Quantities in stock: 10
  1121.  
  1122. ---------------------------------
  1123. Title: Dynamic InterWeb Programming
  1124. ISBN: 22-99521-453-1
  1125. Publisher: GNet
  1126. Year of Publication: 1998
  1127. Number of Authors: 1
  1128. Authors: Goof, Goofy;
  1129. Price: 39.99
  1130. Quantities in stock: 29
  1131.  
  1132. ---------------------------------
  1133. Welcome to Rock's Book Store
  1134. To make a selection enter the number and press enter
  1135. 1: Print a list of books
  1136. 2: Print a list of books and ISBN numbers
  1137. 3: To see if a book in store
  1138. 4: To update the number of copies of a book
  1139. 5: To print books data
  1140. 9: Exit the program.
  1141.  
  1142. 9
  1143.  
  1144. --------------------------------
  1145. Process exited with return value 0
  1146. Press any key to continue . . .
  1147.  
  1148.              
  1149. create new paste  /  dealsnew!  /  syntax languages  /  archive  /  faq  /  tools  /  night mode  /  api  /  scraping api  /  go  
  1150. privacy statement  /  cookies policy  /  terms of service  /  security disclosure  /  dmca  /  contact
  1151.  
  1152. By using Pastebin.com you agree to our cookies policy to enhance your experience.
  1153. Site design & logo © 2018 Pastebin; user contributions (pastes) licensed under cc by-sa 3.0 -- Dedicated Server Hosting by Steadfast   Top
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement