Question: C++ Programming, using namespace std and iostream. You were given two text files with comma separated values: books.txt, which is a list of books and

C++ Programming, using namespace std and iostream. You were given two text files with comma separated values: books.txt, which is a list of books and their authors, and ratings.txt, which is a list of users and their ratings of those books. The first task is to read these files and load their contents into arrays for convenient processing. Sample lines from books.txt: Douglas Adams,The Hitchhiker's Guide To The Galaxy Richard Adams,Watership Down Mitch Albom,The Five People You Meet in Heaven (etc.) - The format is , Sample lines from ratings.txt: cynthia,4 3 1 0 3 0 5 1 5 2 2 2 1 4 4 2 0 1 1 2 3 2 1 1 3 4 1 2 1 3 0 0 3 1 1 3 2 3 1 2 3 4 5 5 0 1 3 2 2 4 diane,3 1 1 0 2 2 3 1 0 1 4 3 1 2 1 1 5 2 4 0 3 2 1 5 4 5 0 2 3 3 5 2 2 1 4 5 2 4 5 2 3 3 5 5 4 1 3 4 2 3 (etc.) - The format is <username>,<rating_0> <rating_1> <rating_2> <rating_50> - The order of ratings, rating_0, rating_1, rating_2,... correspond to the order of books in the books.txt file Note: For this homework, assume there are 50 books and 100 users at the max(86 users to be exact).</p> <p> <strong>Question 1</strong> Write a function readBooks that populates a pair of arrays with the titles and authors found in books.txt. This function should: Accept five input arguments in this order: string: the name of the file to be read string array: titles string array: authors int: the number of </p> <p> <strong>Question 2</strong> Write a function readRatings that performs a similar task on the user ratings file. Each username represented in ratings.txt is followed by list of integers--ratings of each book in books.txt. Rating Meaning 0 Did not read 1 Hell No - hate it!! 2 Dont like it. 3 Meh - neither hot nor cold 4 Liked it! 5 Mind Blown - Loved it! Your function should: Accept six arguments in this order: string: the name of the file to be read string array: usernames 2D int array: list of ratings for each user (first index specifies user) int : number of users currently stored in the arrays int: row capacity of the 2D array (convention: array[row][column]) [assume to be 100] int: column capacity of the 2D array [assume to be 50] Use ifstream, stringstream, and getline to read and parse data from the file, placing usernames in the usernames array and book ratings in the ratings array (stoi will also be useful here) Print the username of each user as they are added to the system cout << username << "..." << endl; Return the total number of users in the system, as an integer. If the file cannot be opened, return -1 Hint: You can use the split() function that was used during recitation Note: Although user can specify the name of the file to read from, assume the default filename to be ratings.txt Expected output: cynthia... diane... joan... barbara... (etc.)</p> <p> <strong>Question 3</strong> It will be useful to display the contents of your library. Next, make a function printAllBooks that meets the following criteria: Accept three arguments in this order: string array: titles string array: authors int: number of books This function does not return anything If the number of books is 0, print No books are stored Otherwise, print Here is a list of books and then each book in a new line using the following statement cout << titles[i] << " by " << authors[i] << endl; Expected output (assuming you have read the data from books.txt) The Hitchhiker's Guide To The Galaxy by Douglas Adams Watership Down by Richard Adams The Five People You Meet in Heaven by Mitch Albom Speak by Laurie Halse Anderson (etc.)</p> <p> <strong>Question 4</strong> Write a function getUserReadCount for determining how many books a particular user has read and reviewed. This function should: Accept five arguments in this order: string: username for whom we want a read count string array: all users 2D int array: list of all ratings, one row for each user int: number of users in the arrays int: number of books accounted for in the 2D array Return the number of books read/reviewed by the specified user, as an integer. If the program has not read ratings.txt or books.txt, it must read it first before executing this function. In this case, return -1 after printing the following message: cout << name << " does not exist in the database" << endl; If instead the database is initialized but the user is not found, return -1 after printing the following message : cout << name << " does not exist in the database" << endl; Highly recommend: Write a helper function that searches the user array for a particular username and returns its index.</p> <p> <strong>Question 5</strong> Finally, create a function calcAvgRating that returns the average (mean) rating for a particular book. This function should: Accept five arguments in this order: string: book title for which you want the average rating string array: titles 2D int array: list of ratings for each user (same comment here) int: number of users in the arrays int: number of books accounted for in the 2D array Return the average rating of the specified book as a double If the program has not read ratings.txt or books.txt, it must read it first before executing this function. In this case, return -1 after printing the following message: cout << bookTitle << " does not exist in the database" << endl; If instead the database is initialized but the book is not found, return -1 after printing the following message: cout << bookTitle << " does not exist in the database" << endl; Highly recommend: Write a helper function that searches the titles array for a particular book and returns its index. Note: If the user has not reviewed the book it should not be added while calculating the average.</p> <p> <strong>Driver function</strong></p> <p>The menu will run on a loop, continually offering the user six options until they opt to quit.</p> <p>Example menu Select a numerical option: ======Main Menu===== 1. Read book file 2. Read user file 3. Print book list 4. Find number of books user rated 5. Get average rating 6. Quit</p> <p>1. Initialize library Prompt the user for a file name. Pass the file name to your readBooks function. Print the total number of books in the database in the following format: Total books in the database: If no books are saved to the database due to wrong file name, then print the following message: No books saved to the database</p> <p>2. Initialize user catalog Prompt the user for a file name. Pass the file name to your readRatings function Print the total number of users in the database in the following format: Total users in the database: If no books are saved to the database due to wrong file name, then print the following message: No users saved to the database</p> <p>3. Display library Call your printAllBooks function.</p> <p>4. Get number of books reviewed by a user Prompt the user for a username. Pass the username to your getUserReadCount function If the user exists in the system, print the result in the following format: rated books</p> <p>5. Get average rating for a title Prompt the user for a title. Pass the title to your calcAvgRating function If the title exists in the database, print the result in the following format: The average rating for is Note: is a double with 2 decimal points.</p> <p>6. Quit Print good bye! before exiting</p> </div> <div class="question-answer-divider"></div> <section class="answerHolder" itemscope itemtype="http://schema.org/Answer"> <div class="answerHolderHeader"> <h2>Step by Step Solution</h2> <div class="answerReviews"> <div class="starIcon"> </div> </div> </div> <div class="questionProperties"> <p>There are 3 Steps involved in it</p> <div class="cart-flex"> <div class="cart cart1"> 1 Expert Approved Answer </div> </div> </div> <div class="step org_answer"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="step-heading step-1">Step: 1 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> <img src="https://www.solutioninn.com/includes/images/document_product_info/blur-text-image.webp" class="blured-ans-image" width="759" height="271" alt="blur-text-image" decoding="async" fetchpriority="high"> <div class="step1Popup"> <span class="heading">Question Has Been Solved by an Expert!</span> <p>Get step-by-step solutions from verified subject matter experts</p> <button class="view_solution_btn step1PopupButton">View Solution</button> </div> </div> <div class="step"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="accordion step-heading">Step: 2 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> </div> <div class="step"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="accordion step-heading">Step: 3 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> </div> </section> <section class="relatedQuestion"> <h3>Students Have Also Explored These Related Databases Questions!</h3> <div class="relatedQuestionSliderHolder"> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/you-were-given-two-text-files-with-comma-separated-values-13306472" > You were given two text files with comma separated values: books.txt, which is a list of books and their authors, and ratings.txt, which is a list of users and their ratings of those books. The first... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/you-were-given-two-text-files-with-comma-separated-values-13326213" > You were given two text files with comma separated values: books.txt, which is a list of books and their authors, and ratings.txt, which is a list of users and their ratings of those books. Write a... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/1411116-programming-i-assignment-3-due-date-november-30-10626058" > 1411116 - Programming I Assignment #3 Due Date: November 30, 2016 Submission Instructions: Submit your assignment on the blackboard link, corresponding to your Section: Please follow the following... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/bookcpp-file-booklist-sequence-containers-homework-last-updated-friday-february-13748246" > book.cpp file BookList Sequence Containers Homework Last updated: Friday, February 12, 2021 The following class diagrams should help you visualize the BookList interface, and to remind you what the... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/hi-please-help-me-with-the-following-question-and-code-17386196" > Hi, please help me with the following question and code it in C++. And please if you are not getting the question don't answer it because I already received 4 incorrect answers and this is 5th time... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/hi-please-help-me-with-the-following-problem-and-please-13847944" > Hi, please help me with the following problem and please if you are not getting the question don't answer it. This question has a pre coded file that i am attaching the screenshots of that with this... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/cpsc131-project-3-universal-product-code-upc-catalog-this-project-12519653" > CPSC-131 Project 3: Universal Product Code (UPC) Catalog This project is different from the previous two. In project 1, you were not allowed to use the C++ Standard Library (SL); in project 2, you... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/universal-product-code-upc-catalog-in-this-project-you-are-13848534" > Universal Product Code (UPC) Catalog In this project, you are required to use the SL map, std::map, to apply this binary search tree to a real problem. The project files provide one class, Catalog,... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/i-need-help-with-my-computer-science-assignment-its-in-12551182" > I need help with my computer science assignment. its in C++ language. This project is different from the previous two, where you were given skeleton classes with member functions to complete. Its... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/data-structures-lab-3-this-assignment-tests-the-concepts-of-13562111" > Data Structures Lab 3 This assignment tests the concepts of: Containers Static arrays Program Objective: Implement 2 non-member functions and one member function. The provided driver code reads in a... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/claim-d-0-005-sample-statistics-" > Claim: d </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/in-the-midst-of-a-conflict-why-is-it-importanis-it-important-192023" > In the midst of a conflict, Why is it important to address the four different emergent problems? Why is it important that all parties involved in a conflict understand the follow-up plan? </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/the-accounts-below-appear-in-the-ledger-of-ivanhoe-company-27931342" > The accounts below appear in the ledger of Ivanhoe Company. From the postings in the accounts above, indicate how the information is reported on a statement of cash flows by preparing a partial... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/compared-with-half-a-century-ago-adoption-has-become-15204873" > Compared with half a century ago, adoption has become _ _ _ _ _ _ _ _ _ common, but it is more open and acceptabl e , so we probably discuss it _ _ _ _ _ _ _ . fill in the blanks more or much less or... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/marketing-strategy-planning/question-what-is-the-doughnut-hole-in-hsa-coverage-2125741" > Question What is the doughnut hole in HSA coverage? </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/marketing-strategy-planning/question-may-a-taxpayer-roll-over-unused-balances-from-2125744" > Question May a taxpayer roll over unused balances from health reimbursement arrangements (HRAs) or health flexible spending accounts (health FSAs)? </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/marketing-strategy-planning/question-can-an-hsa-be-designed-to-provide-benefits-2125740" > Question Can an HSA be designed to provide benefits primarily for a selected group of executives? </a> </div> </div> <nav class="navigationButtons"> <a class="previousQuestionButton" href="/study-help/questions/the-four-types-of-creep-are-scope-13525922">Previous Question</a> <a class="nextQuestionButton" href="/study-help/questions/c-programming-assignment-2-unit-conversion-tables-this-programming-project-13525924">Next Question</a> </nav> </section> </main> <aside class="expertRight"> <section class="relatedBook" style="margin-bottom:40px; width: 100%;" > <div class="bookHolder" > <div class="relatedBookHeading" > <h2 class="heading">Recommended Textbook</h2> </div> <div class="bookMainInfo" > <div class="bookImage" style="width: 100px !important; min-width: 100px; flex-shrink: 0; margin-right: 20px;"> <a href="/textbooks/database-and-expert-systems-applications-33rd-international-conference-dexa-2022-vienna-austria-august-22-24-2022-proceedings-part-2-lncs-13427-1st-edition-978-3031124259-175977"> <img src="https://dsd5zvtm8ll6.cloudfront.net/si.question.images/book_images/2024/01/6597e5c3e1203_5716597e5c3dbc14.jpg" width="100" height="131" alt="Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427" loading="lazy" style="width: 100px !important;"> </a> <a href="/textbooks/computer-science-applications-660" style="margin-top: 8px; display: block; text-align: left;">More Books</a> </div> <div class="bookInfo" style="text-align: left;"> <span class="bookTitle" style="text-align: left;"> <a href="/textbooks/database-and-expert-systems-applications-33rd-international-conference-dexa-2022-vienna-austria-august-22-24-2022-proceedings-part-2-lncs-13427-1st-edition-978-3031124259-175977" style="text-align: left;"> Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427 </a> </span> <div class="bookMetaInfo" style="text-align: left;"> <p class="bookAuthor" style="text-align: left;"> <b>Authors:</b> <span>Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil</span> </p> <p class="bookEdition" style="text-align: left;"> 1st Edition </p> <p class="bookEdition" style="text-align: left;"> 3031124251, 978-3031124259 </p> </div></div></div> </div> </section> <div class="post-question-section"> <div class="description-question-section"> <span class="post-question-section-title">Ask a Question and Get Instant Help!</span> </div> <div class="text-area-post-question"> <form action="/study-help/post-question?ref=search" method="post" enctype="multipart/form-data"> <textarea rows="4" class="form-control form-posting-margin" name="textarea-question-content" id="textarea-question-content" placeholder="Type Your Question ...."></textarea> <button type="submit" class="btn btn-sm btn-submit-post-question text-center">Get Answer</button> </form> </div> </div> </aside> </div> </div> <div class="promo items-center justify-center hidden"> <div class="app_promo"> <span class="app_promo_dismiss"> <i class="fa-solid fa-x"></i> </span> <div class="app-button"> <div class="image-wrapper"> <img width="30" height="30" src="https://www.solutioninn.com/includes/images/rewamp/common/mobile-app-logo.png" decoding="async" fetchpriority="high" alt="SolutionInn App Logo"> <strong>Study Help</strong> </div> <button class="app_promo_action redirection" data-question-open-url='q_id=13525923&q_type=2'> Open in App </button> </div> </div> </div> </div> </div> <div class="blank-portion"></div> <footer> <div class="container footerHolder"> <div class="footerLinksFlex"> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Services</p> <ul> <li><a href="/site-map">Sitemap</a></li> <li><a href="/fun/">Fun</a></li> <li><a href="/study-help/definitions">Definitions</a></li> <li><a href="/tutors/become-a-tutor">Become Tutor</a></li> <li><a href="/books/used-textbooks">Used Textbooks</a></li> <li><a href="/study-help/categories">Study Help Categories</a></li> <li><a href="/study-help/latest-questions">Recent Questions</a></li> <li><a href="/study-help/questions-and-answers">Expert Questions</a></li> <li><a href="/clothing">Campus Wear</a></li> <li><a href="/sell-books">Sell Your Books</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Company Info</p> <ul> <li><a href="/security">Security</a></li> <li><a href="/copyrights">Copyrights</a></li> <li><a href="/privacy">Privacy Policy</a></li> <li><a href="/conditions">Terms & Conditions</a></li> <li><a href="/solutioninn-fee">SolutionInn Fee</a></li> <li><a href="/scholarships">Scholarship</a></li> <li><a href="/online-quiz">Online Quiz</a></li> <li><a href="/study-feedback">Give Feedback, Get Rewards</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Get In Touch</p> <ul> <li><a href="/about-us">About Us</a></li> <li><a href="/support">Contact Us</a></li> <li><a href="/career">Career</a></li> <li><a href="/jobs">Jobs</a></li> <li><a href="/support">FAQ</a></li> <li><a href="https://www.studentbeans.com/en-us/us/beansid-connect/hosted/solutioninn" target="_blank" rel="noopener nofollow">Student Discount</a></li> <li><a href="/campus-ambassador-program">Campus Ambassador</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-12"> <p>Secure Payment</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder"> <img src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/common/footer/secure_payment_method.png" class="img-fluid mb-3" width="243" height="28" alt="payment-verified-icon" loading="lazy"> </div> </div> <p>Download Our App</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6 redirection" data-id="1"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/google-play-svg.svg" alt="SolutionInn - Study Help App for Android" width="116" height="40" class="img-fluid mb-3 " loading="lazy"> </div> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6 redirection" data-id="2"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/apple-store-download-icon.svg" alt="SolutionInn - Study Help App for iOS" width="116" height="40" class="img-fluid mb-3" loading="lazy"> </div> </div> </div> </div> </div> <div class="footer-bottom"> <p>© 2026 SolutionInn. All Rights Reserved</p> </div></footer> <script> window.addEventListener("load",function(){jQuery(document).ready(function(t){ // Clarity tracking (function(c,l,a,r,i,t,y){ c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); })(window, document, "clarity", "script", "sjv6tuxsok"); // Helper to read a cookie by name function getCookie(name) { return document.cookie .split('; ') .map(v => v.split('=')) .reduce((acc, [k, val]) => (k === name ? decodeURIComponent(val || '') : acc), ''); } // Read cookies var si = getCookie('si_u_id'); var uid = getCookie('u_id'); var zen = getCookie('zenid'); // Send to Clarity if (si) clarity('set', 'si_u_id', si); if (uid) clarity('set', 'u_id', uid); if (zen) clarity('set', 'zenid', zen); clarity('set', 'ip_address', '216.73.216.134'); t.ajax({type:"POST",url:"/",data:{trackUserActivity:!0,reqUri:document.URL,referer:document.referrer},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(t){t.ajax({type:"POST",url:"/",data:{insertCrawler:!0,reqUri:document.URL,parseTime:"0.056",queryTime:"0.01654768548584",queryCount:"30"},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(){function t(t="",n=!1){var i="itms-apps://itunes.apple.com/app/id6462455425",e="openApp://action?"+t;isAndroid()?(setTimeout(function(){return window.location="market://details?id=com.solutioninn.studyhelp",!1},25),window.location=e):isIOS()?(setTimeout(function(){return window.location=i,!1},25),window.location=e):(i="https://apps.apple.com/in/app/id6462455425",n&&(i="https://play.google.com/store/apps/details?id=com.solutioninn.studyhelp"),window.open("about:blank","_blank").location.href=i)}jQuery("#appModal").modal("show"),jQuery(".download-app-btn").click(function(){t(jQuery(this).attr("data-question-open-url"))}),jQuery(".redirection").click(function(){var n=jQuery(this).attr("data-question-open-url"),i=jQuery(this).attr("data-id");void 0!=n?1==i?t(n,!0):t(n,!1):1==i?t("",!0):t("",!1)}),jQuery(".app-notification-close").click(function(){jQuery(".app-notification-section").css("visibility","hidden");var t=new FormData;t.append("hide_notification",!0),jQuery.ajax({type:"POST",url:"/",data:t,cache:!1,contentType:!1,processData:!1,beforeSend:function(){},success:function(t){location.reload()}})})})},!1); </script> </body> </html>