Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following input file: 5 C++Programing: From Problem Analysis to Program Design 5-17-525281-3 ABC 2000 52.50 20 1 Malik, D.S. Fuzzy Discrete Structures 3-7908-1335-4

Given the following input file:

5 C++Programing: From Problem Analysis to Program Design 5-17-525281-3 ABC 2000 52.50 20 1 Malik, D.S. Fuzzy Discrete Structures 3-7908-1335-4 Physica-Verlag 2000 89.00 10 2 Malik, Davender Mordeson, John Fuzzy Mathematic in Medicine 3-7908-1325-7 Physica-Verlag 2000 89.00 10 3 Mordeson, John Malik, Davender Cheng, Shih-Chung Harry John and The Magician 0-239-23635-0 McArthur A. Devine Books 1999 19.95 10 3 Goof, Goofy Pluto, Peter Head, Mark Dynamic InterWeb Programming 22-99521-453-1 GNet 1998 39.99 25 1

I need to be able to make a bookTypeImp.cpp and bookType.h file that corresponds to the following program:

#include #include #include #include "bookType.h"

using namespace std;

void getBookData(bookType books[], int& noOfBooks); void printBookData(bookType books[], int noOfBooks); void searchBookData(bookType books[], int bookCount); void searchBookDataByISBN(bookType books[], int bookCount, string ISBN, int& loc); void searchBookDataByTitle(bookType books[], int bookCount, string title, int& loc); void updateCopiesInStock(bookType books[], int bookCount); void showMenu(); void subMenu();

int main() { bookType books[100];

int numberOfBooks = 0;

int choice;

int i;

getBookData(books, numberOfBooks);

showMenu(); cin >> choice;

while (choice != 9) { switch (choice) { case 1: for (i = 0; i books[i].printbookTitle(); cout << endl; break; case 2: for (i = 0; i books[i].printbookTitleAndISBN(); cout << endl; break; case 3: searchBookData(books, numberOfBooks); break; case 4: updateCopiesInStock(books, numberOfBooks); break; case 5: printBookData(books, numberOfBooks); break; default: cout << "Invalid selection." << endl; }

showMenu(); cin >> choice; }

return 0; }

void getBookData(bookType books[], int& noOfBooks) { string title; string ISBN; string Publisher; int PublishYear; string auth[4]; double cost; int copies; int authorCount;

int i, j;

ifstream infile; char ch;

infile.open("bookData.txt");

if (!infile) { cout << "Cannot open Input file" << endl; cout << "Exit the program" << endl; return; }

infile >> noOfBooks; infile.get(ch);

for (i = 0; i < noOfBooks; i++) { getline(infile, title); getline(infile, ISBN); getline(infile, Publisher); infile >> PublishYear >> cost >> copies >> authorCount; infile.get(ch);

for (j = 0; j < authorCount; j++) getline(infile, auth[j]);

books[i].setBookInfo(title, ISBN, Publisher, PublishYear, auth, cost, copies, authorCount); } }

void printBookData(bookType books[], int noOfBooks) { int i;

for (i = 0; i < noOfBooks; i++) { books[i].printInfo(); cout << endl << "---------------------------------" << endl; } }

void searchBookDataByISBN(bookType books[], int bookCount, string ISBN, int& loc) { int i; loc = -1;

for (i = 0; i < bookCount; i++) if (books[i].isISBN(ISBN)) { loc = i; break; } }

void searchBookDataByTitle(bookType books[], int bookCount, string title, int& loc) { int i; loc = -1;

for (i = 0; i < bookCount; i++) if (books[i].isTitle(title)) { loc = i; break; } }

void searchBookData(bookType books[], int bookCount) { int choice; char ch;

int loc;

string str;

subMenu();

cin >> choice; cin.get(ch);

switch (choice) { case 1: cout << "Enter the ISBN of the book." << endl; getline(cin, str); searchBookDataByISBN(books, bookCount, str, loc); if (loc != -1) cout << "The store sells this book." << endl; else cout << "The store does not sell this book" << endl; break; case 2: cout << "Enter the title of the book." << endl; getline(cin, str); searchBookDataByTitle(books, bookCount, str, loc); if (loc != -1) cout << "The store sells this book." << endl; else cout << "The store does not sell this book" << endl; break; default: cout << "Invalid choice" << endl; } }

void updateCopiesInStock(bookType books[], int bookCount) { int choice;

int loc;

int count; char ch;

string str;

subMenu(); cin >> choice; cin.get(ch);

switch (choice) { case 1: cout << "Enter the ISBN of the book." << endl; getline(cin, str); searchBookDataByISBN(books, bookCount, str, loc); if (loc != -1) { cout << "Enter the number of books: "; cin >> count; cout << endl;

books[loc].updateQuantity(count); } else cout << "The store does not sell this book: " << endl; break; case 2: cout << "Enter the title of the book." << endl; getline(cin, str); searchBookDataByTitle(books, bookCount, str, loc); if (loc != -1) { cout << "Enter the number of books"; cin >> count; cout << endl;

books[loc].updateQuantity(count); } else cout << "The store does not sell this book" << endl; break; default: cout << "Invalid choice" << endl; } }

void showMenu() { cout << "Welcome to Rock's Book Store" << endl; cout << "To make a selection enter the number and press enter" << endl; cout << "1: Print a list of books" << endl; cout << "2: Print a list of books and ISBN numbers" << endl; cout << "3: To see if a book in store" << endl; cout << "4: To update the number of copies of a book" << endl; cout << "5: To print books data" << endl; cout << "9: Exit the program." << endl; }

void subMenu() { cout << "Enter" << endl; cout << "1: To search the book by ISBN" << endl; cout << "2: To search the book by title" << endl; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago