Array help!

Trying to ask the user what book id they want, and then how many copies, and then what the total for that would be. I'm stuck...
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
82
83
84
85
86
87
88
89
90
91
92
93
  #include <iostream>
#include <string>
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;

    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;
int numCopies;
int total = numCopies * bookPrice;
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;
    cout << "How many copies do you want?: ";
    cin >> numCopies;
    cout << "Your total is " << total << endl;
}

if (choice == 3){

    for (int x = 1; x<1000; x++){
        cout << rand()%500 << endl;
    }


}

return 0;

}
}
Topic archived. No new replies allowed.