Here is the code i have to do this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
# 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");
}
|
But i realise that the if title== allTitles [300] would not work correctly
as i have only limited records
basically i want to define it like so
Int TotalRec = 2
while I=0 <TotalRec I++)
Then I need it to perform a check on the elements in the Array all titles
which i have used a cin statement to cin data
If it finds a match it will also output for example if element 3 is a match it will cout element 3 in allTitles and element 3 in All Prices
then i was thinking of putting return true as it is a boolean value
then defining a secondary check that if it is != to allTitles []
cout " No Books found
return false;
how would i write this check as i am struggling to follow it
any help would be greatly appreciated Thanks
I am quite happy for people to edit my code but the bool function must not be changed except for the array sizes.