Question: Objectives: conditions, loops, abstract data type, arrays, multiple source files and file I/O. Write a Textbook Information Viewing program. This project requires a user-defined struct

Objectives: conditions, loops, abstract data type, arrays, multiple source files and file I/O.

Write a Textbook Information Viewing program. This project requires a user-defined struct type. A book.h header file, declared below, is used to represent each textbook record in the system and functions that you need to implement. Implement the declared textbook functions in a file named book.cpp. Develop a program, name proj01.cpp, to read from input textbook data record file and create a list of textbook records. The input data file can store up to 35 textbook records. This program can perform 2 functions

  • List: to list all the textbook records read from the input file
  • Find: to lookup a specific textbook record by the input ISBN number. The ISBN number is an alphanumeric value.

Your program will read all input from the command line, no prompting for user input and hardcoding for input file name. The required program output is provided below

Declaration of Book struct:

// @file book.h

#ifndef BOOK_H

#define BOOK_H

#include using namespace std;

const int MAX_AUTHORS = 20;

struct Book {

string title;

string authors[MAX_AUTHORS];

short authorCount;

string publisher;

short yearPublish;

bool hardcover;

float price;

string isbn;

long copies;

};

/**

  • @param filename name of the input data file
  • @param books[] an array of textbook records read from the file

*

  • @return the number of textbook records read

*/

int read (string filename, Book books[]);

/**

  • @param id the ISBN number to search for
  • @param books[] the list of textbook records
  • @param length the number of textbook records in the array

*

  • @return the array index of the matching record, otherwise it returns -1 */

int find (string id, Book books[], int length);

#endif /* BOOK_H */

Example Output:

% cat book.dat

C++ Network Programming Volume 1

2

Douglas C. Schmidt

Stephen D. Huston

Addison-Wesley

2002

0

35.99

0-201-60464-7

236

Programming Ruby

2

David Thomas

Andrew Hunt

Addison-Wesley

2001

0

42.95

0-201-71089-7

123

Problem Solving with C++ - The Object of Programming

1

Walter Savitch

Addison Wesley Longman, Inc.

2001

0

74.00

0-201-70390-4

325 ...

% ./proj01

./proj01 find

./proj01 list

% ./proj01 books.dat list

Title: C++ Network Programming - Volume 1

Author: Douglas C. Schmidt

Author: Stephen D. Huston

Publisher: Addison-Wesley

Year: 2002

Cover: Paperback

Price: $35.99

ISBN: 0-201-60464-7

Copies: 236

Title: Programming Ruby

Author: David Thomas

Author: Andrew Hunt

Publisher: Addison-Wesley

Year: 2001

Cover: Paperback

Price: $42.95

ISBN: 0-201-71089-7 Copies: 123 ...

% ./proj01 books.dat find 0-201-60464-7

ISBN: 0-201-60464-7 -- FOUND

Title: C++ Network Programming - Volume 1

Author: Douglas C. Schmidt

Author: Stephen D. Huston

Publisher: Addison-Wesley

Year: 2002

Cover: Paperback

Price: $35.99

ISBN: 0-201-60464-7

Copies: 236

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!