Now I HAve Written The following Programs
# include <iostream>
# include <string>
# define MAXSIZE = 300
using namespace std;
bool findTitlePrice(string allTitles[300], double allPrices [300],int totalRec,string title,double price);
string allTitles[300] = {
"Book 1",
"Book 2"};
double allPrices[300] = {
78.5, 66.
};
int main ()
{
bool findTitlePrice(string allTitles [300], double allPrices [300],int totalRec,string title,double price);
int totalRec =2;
for(int i=0;i<totalRec;i++);
string Title;
string allTitles [300];
cout << "Please Enter Title";
cin >> Title;
if (Title == allTitles [300])
cout <<"Value Found";
if (Title != allTitles [300]) cout << " Book Not Found ";
system ("pause");
}
# include <iostream>
# include <string>
# define MAXSIZE = 300
using namespace std;
bool findTitlePrice(string allTitles[MAXSIZE],double allPrices[MAXSIZE],int totalRec,string title,double price);
string allTitles[MAXSIZE] ={
"Book 1",
"Book 2"
};
double allPrices[MAXSIZE] = {
78.5, 66.0 };
int main ()
{
int totalRec =2;
string title;
double price;
findTitlePrice( string allTitles, double allPrices,totalRec,title,price);
}{
bool findTitlePrice(string allTitles [],double allPrices [],int totalRec , string title ,double price);
for (int i=0; i<totalRec; i++) {
cin >> title;
if (title==allTitles[i])
{
cout << " Book Found";
cout <<" Here is The Title of the Book" << allTitles [i];
cout << " Here is The Price Of the Matched Book" <<allPrices [i];
return true;
}
else {
cout << " Book Not Avaliable";
return false;
}//End of For Statment
system ("pause");}
}
The Second one is closer to my goal though i haven't defined this very well
Basically
The Progrm must use the boolFindPrice Function which i will set to maxsize as it is too have 300 max elements in each array
Totalrec = 2 at this stage as it is the number of elements stored in each array
The Program must store the two arrays and the data
as shown
Then it must take the Cin input and compare it to the alltitles array which i was thinking of using
for (i=0 <MAxsize,I++)
{ Cin >> Title;
if (Title == allTitles [MaxSIZE]) or something similar to this to check all the elements in the allTitles array then if it finds a match cout the title and the corresponding price form the allPrices array such as if element 3 in all titles is a match cout the title stored and the price stored in element 3 of all prices.
The if a match is found return true else return false
I am 100% certain i have not prototyped these correctly but the top program complies with errors but is not structured right
Any Help on This would Be Greatly Appreciated
Thanks