I don't know where to begin:

Lab 5
Write a program that will first fill two out of three parallel arrays (local to the main function)
with user-supplied data and then give users the choice to query the parallel arrays. The first
array is as follow:
char title[SIZE_ROW][SIZE_COL]={"Intro to Calculus", "C++
Programming", "Java Programming", "Intro to Psychology", "Intro
to Business"};
Call a function with the following prototype:
void getInput(char t[][SIZE_COL],char a[][SIZE_COL], double p[],
int size);
to fill in the other two local arrays, authors and price.
Next, give the user the choice of searching based on the title, the author, or the price. When the
user supplies one piece of data (for example: the author), find all matches and print the other two
pieces of data( for example: the title and price).
If the user chooses to search by title, call a function with the following prototype:
void searchTitle(char input[], char t[][SIZE_COL],char
a[][SIZE_COL], double p[], int size);
The functions searches the entire title array and each time it finds a match with input it
prints out the corresponding author and price. Use the following functions when searching by
author or price:
void searchAuthor(char input[], char t[][SIZE_COL],char
a[][SIZE_COL], double p[], int size);
void searchPrice(double price, char t[][SIZE_COL],char
a[][SIZE_COL], double p[], int size);
Example:

Write a program that will first fill two out of three parallel arrays (local to the main function)
with user-supplied data and then give users the choice to query the parallel arrays. The first
array is as follow:
char title[SIZE_ROW][SIZE_COL]={"Intro to Calculus", "C++
Programming", "Java Programming", "Intro to Psychology", "Intro
to Business"};
Call a function with the following prototype:
void getInput(char t[][SIZE_COL],char a[][SIZE_COL], double p[],
int size);
to fill in the other two local arrays, authors and price.

Can you implement the program up until this point? Try to get that far based on what you already know from class, post your effort thusly and someone should be able to help you.

Can you implement the program up until this point? Try to get that far based on what you already know from class, post your effort thusly and someone should be able to help you.

thank you i'll give it a shot

Say you had an array of titles an array of authors and an array of prices. Imagine it in a table format:

Index        Author       Title         Price
0              Smith        Why?          10.00
1              Jones        My Book      15.00
2              Jonsca       What?         25.00

So the author array would hold Smith, Jones, and Jonsca but the index of the author would be the same as the index of his book in the book array. So one your functions will allow you to ask who is the author of the book "My Book"

if the user chooses to search by title, call a function with the following prototype:
void searchTitle(char input[], char t[][SIZE_COL],char
a[][SIZE_COL], double p[], int size);

So you'd pass this function: the title you were looking for, the array of titles, the array of authors, the array of prices, and the size for all these arrays (since we're keeping the indexes lined up they should all have the same size). You'd check each entry in the titles array for the one you entered and then get the appropriate index which can be used in the author array to find that it is Jones's book.

Edited 6 Years Ago by jonsca: n/a

but wasn't detailed

That's because I can't have all the fun... :)

Get some of the initial set-up done with the arrays declared and try the getInput function (as those parts are probably not new to you) and post back with what you have. You must put forth the effort and we will be glad to help.

This article has been dead for over six months. Start a new discussion instead.