Need help with this Array Question

How would I ask the user how many of the searched book they want, and then output the total? I've looked in my textbook, and I can't figure it out.
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;




int linearSearch(int bookId[], int size, int searchValue)
{
    for (int i = 0; i < size; i++)
    {
        if (searchValue == bookId[i])
        {
            return i;
        }
    }
    return -1;
}






int main()

{



    int choice;
    int a;
    int j;
    int tmp;

    cout << endl;
    cout << "Choose from the menu below: " << endl;
    cout << "1: Linear Search" << endl;
    cout << "2: Binary Search" << endl;
    cout << "3: Bubble Sort" << endl;
    cout << "4: Selection Sort" << endl;
    cout << "5: Quit" << endl;
    cin >> choice;


if (choice == 1) {
string bookTitle[10] = {"Starting Out With C++" ,"Java Programming",
"Software Structures" , "Deisgn and Analysis of Algorithms" , "Computer Graphics",
 "Artifical Inteligence: A Modern Approach" , " Probability and Statistics" , "Cognitive Science" ,
 "Modern Information Retrieval" , "Speech and Language Processing"};

int bookId[10] = {1101, 1211, 1333, 1456, 1567, 1642, 1699, 1755, 1800, 1999};

double bookPrice[10] = {112.32, 73.25, 54.00, 67.32, 135.00, 173.22, 120.00, 42.25, 32.11, 123.75};

cout << "Book ID" << "   " << "Book Name" << "             " << "Book Price" << endl;
    for(int x = 0; x < (10); x++)
{
	cout << bookId[x] << "   " << bookTitle[x] << "   " << "$" << bookPrice[x] << endl;
}

int userValue;

cout << "Enter in a book ID: " << endl;
cin >> userValue;

int result = linearSearch(bookId, 10, userValue);

if (result >= 0)
{
   cout << "The number " << bookId[result] << " was found" << endl;
}
else
{
    cout << "The Book ID " << userValue << " was not found" << endl;


}
}
Topic archived. No new replies allowed.