Design your application according to the considerations

Assignment Help C/C++ Programming
Reference no: EM13161799

Your instructor maintains a database of technical books in his collection.  You will find a copy of this database in the file: library.txt which is part of this assignment. The format of this file is such that every book occupies two lines. The first line contains the title and the second line contains the author or authors.

Your first task is to write a program which reads this file into two parallel arrays in memory. One array contains the titles, and the other array contains the authors. The arrays are 'parallel' in the sense that the n-th element of the authors array contains the authors associated with the n-th element of the titles array. Although the data in the test file describes only a few books you should dimension your arrays for an arbitrary number of books in the live data file (which may be different from the test file). The size of the arrays should be defined in your program by the declaration const int ARRAY_SIZE = 1000.

For the purpose of this assignment (so as not to make it too complicated) you should declare your two arrays at filescope (i.e. outside any function and before the function main()). The declarations should be as follows:

string bookTitle [ARRAY_SIZE];

string bookAuthor [ARRAY_SIZE];

Write a function whose signature is as follows:

int loadData (string pathname)

The function loadData should open the data file located in the path on your hard disk specified by pathname. If it cannot open the file for some reason, it should return a value of -1 as an error result. Otherwise it should read the data in the file into the two parallel arrays, and return the number of book records that it read.

Now write a function whose signature is as follows:

void showAll (int count)

The parameter count provides the number of books actually stored in the database (i.e the value returned by the function loadData()). showAll() should read the designated number of records in the parallel arrays and display it on the screen in the order it appears in the database, in single column format. In this display format the author or authors appear in parentheses following the title, and there is one book record per line of output. For example, using the data in the sample file, the output would look like this:

Objects First with Java  (Barnes and Kolling)

Game Development Essentials (Novak)

The Game Maker's Apprentice (Overmars)

C++ Programming: From Problem Analysis... (Malik)

...

...

Audio for Games (Brandon)

Now test your work so far, by writing a main() function to prompt the user for the path to the data file, open and read the file to the parallel arrays using the function loadData() (providing error messages and recovery as appropriate if the file doesn't exist). Then display the contents of the file using showAll().

Step (2)

Extend your program into a menu driven application to query the database. When the program starts it should ask the user for the path to the data file, and read the data into the parallel arrays, as in step 1.

Then it should enter a loop, in each iteration of which it prompts the user for what they want to do. The actions are as follows depending on how the user responds to the prompt. See the sample dialog below to see how this works in practice.

Q or q: Quit. The program terminates.

S or s: The program displays all the records in the database using the function showAll you have already developed in step (1).

A or a: Search by Author. The program displays all records which contain the designated text somewhere in the author field. You should use a function with the following signature for this purpose: void showBooksByAuthor (int count, string name). This function should display all books whose author field contains the string passed in the parameter called name. count specifies the number of books in the database.

T or t: Search by Title. The program displays all records which contain the designated text somewhere in the title field. You should use a function with the following signature for this purpose: void showBooksByTitle (int count, string title). This function should display all books whose title field contains the string passed in the parameter called title. count specifies the number of books in the database.

Sample Dialog

Note: In the example below, the user's input is in BOLD. The program output is not.

Welcome to [your name here]'s Library Database.

Please enter the name of the backup file: C:\library.txt

14 records loaded successfully.

Enter Q to (Q)uit, Search (A)uthor, Search (T)itle, (S)how All: A

Author's Name: Malik

C++ Programming: From Problem Analysis... (Malik)

C++ Programming: Program Design Including... (D. S. Malik)

2 records found.

Enter Q to (Q)uit, Search (A)uthor, Search (T)itle, (S)how All: A

Author's Name: Goble

0 records found.

Enter Q to (Q)uit, Search (A)uthor, Search (T)itle, (S)how All: T

Title: Game

Game Development Essentials (Novak)

The Game Maker's Apprentice (Overmars)

Game Character Development with Maya (Ward)

Developing Games in Java (Brackeen)

Audio for Games (Brandon)

5 records found.

Enter Q to (Q)uit, Search (A)uthor, Search (T)itle, (S)how All: Q

Design Considerations

1) Please display your name and not mine in the welcome message.

  • It is an essential part of your grade that you design your application according to the considerations described above.  For example, you must use functions that have the specified signatures, and arrays that have the specified declarations.  They are as follows:

// These declarations should be at file scope

const int ARRAY_SIZE = 1000;

string bookTitle  [ARRAY_SIZE];

string bookAuthor [ARRAY_SIZE];

// Function prototypes

int loadData(string pathname);  

void showAll(int count);

void showBooksByAuthor (int count, string name);

void showBooksByTitle (int count, string title);

Reference no: EM13161799

Questions Cloud

During the glorious revolution : During the Glorious Revolution, William and Mary made concessions to Parliament which had what effect on England?
Colonists to publically criticize slavery : The first group of colonists to publically criticize slavery were the:  Puritans.  Quakers.  farmers.  indentured servants.
Explain the relationships and related to each other : Interpret and explain the use case diagram in the Figure 1: book new edition p. 149. Explain the various roles of those using the system and what functions each role requires. Explain the relationships and how the use cases are related to each other.
Entrepreneurial intensity in the revolutionary sector : Companies should strive to position its EI (entrepreneurial intensity) in the revolutionary sector of the frequency-degree entrepreneurial grid in order to achieve best fit with its internal and external environments.
Design your application according to the considerations : Design your application according to the considerations described above.  For example, you must use functions that have the specified signatures, and arrays that have the specified declarations. They are
Write a program that asks a user for a file name and prints : Write a program that asks a user for a file name and prints the number of characters, words, and lines in that file.
The rpn calculator program : The RPN calculator program should read the RPN expression as an entire line from stdin.Input will consist of a single line. After completing the evaluation of the expression, the program should print the contents of the entire stack, starting with th..
Function which correctly sorts three : Write an x8086 HLA Assembly language program that implements a function which correctly sorts three parameters and returns a boolean value in AL which should be set to true if any swaps were performed to sort the sequence in increasing order.
Cashregister class that can be used with the retailitem clas : Write a CashRegister class that can be used with the RetailItem class that you wrote in Part 1. The CashRegister class should simulate the sale of a retail item. It should have a constructor that accepts a RetailItem object as an argument.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Function odd_fill() that fills all integers between two poin

write a function odd_fill() that fills all integers between two pointers, first and last, with a sequence of odd integers: 1,3,5,7

  Skills required by personnel working in information security

What skills are required by personnel working in information security? Write down some job titles in the field and come up with some required qualifications and some desirable qualifications.

  Write main function to compute stress-strain in steel rod

Write a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads.

  Uml diagram of all the classes

Speaking of converting into the correct object-type, the goal of the factory is to abstract away object creation.

  Write a program that converts between app and ppm values

Write a simple program that converts between APP and PPM values

  Multidimensional arrays

multidimensional arrays to life, let's consider a specific example: How can you visualize a 4-dimensional array? How can you give meaning to each dimension this array has? What kind of application would such an array be useful for?

  Principle ofsuperposition to determine that system is linear

Apply the principle of superposition to determine whether the following systems are linear. Sketch what the plot of the function looks like.

  Implement a graphics system that has classes

Implement a graphics System that has classes for various figures: rectangles, squares, triangles and circles. A rectangle has data members height, width, color , and center point. A square has center point and an edge and color

  C program to randomly generate more than ten ip address

Write C or C++ program which Randomly generates more than 10 IP addresses written in decimal format and write results in text file (e.g. Dec_IPAddresses.txt)

  Program to compute diameter in centimeters of a steel rod

Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Programmingto compute the volume of water in the cubic feet

Write down an algorithm (Programming in C) in order to compute the volume of water in the cubic feet, flowing through a pipe of diameter d in feet, having a velocity of v feet per second.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd