Cant figure out how to calculate individual students totals in a loop
<p>I am having an issue with this program.  I need it to ask for a user id then ask for book code and then the cost of a book.  An individual can enter an unknown number of books.  the program needs to then calculate the individual students book total and then ask another student who does the same.  the program must then display the grand totals and total number of books.  I cant seem to figure out what to use to be able to keep track of the individual students entries.  I would be able to do this from what I was reading about arrays.  But we are not to that point yet.  The professor wants us to do this with a loop.  I am so lost, any help would be awesome.  </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;iomanip&gt;

using namespace std;
int main ()
{
    //Declare Variables.
    int student_id;
    char book_code;
    float book_cost;
    float tax_amount;
    float book_subtotal;
    const int SENTINEL = -9999;
    const double TAX = .07;
    float total_book_cost;
    int number_books;
    int total_books_sold;
    double grand_total;

    //Set Variables to Zero.
    number_books = 0;
    total_book_cost = 0.00;
    grand_total = 0.00;

    //Set Decimal to two places.
    cout &lt;&lt; fixed &lt;&lt; showpoint;
    cout &lt;&lt; setprecision(2);

    //Input Data
    cout&lt;&lt;"Please enter your Student ID, then press enter."&lt;&lt;endl;
    cin&gt;&gt;student_id;
    while (student_id != SENTINEL){
        cout&lt;&lt;"Please enter your Book Code, then press enter."&lt;&lt;endl;
        cin&gt;&gt;book_code;
        cout&lt;&lt;"Please enter the cost of the book, then press enter."&lt;&lt;endl;
        cout&lt;&lt;"$"; cin&gt;&gt;book_cost;
        tax_amount = book_cost * TAX;
        book_subtotal = book_cost + tax_amount;
        total_book_cost += book_subtotal;
        number_books++;
        cout&lt;&lt;"\tStudent Textbook Purchases Report"&lt;&lt;endl;
        cout&lt;&lt;"********************************************"&lt;&lt;endl;
        cout&lt;&lt;"Student"&lt;&lt;"\tBook"&lt;&lt;"\tBook"&lt;&lt;"\tTax"&lt;&lt;"\tBook"&lt;&lt;endl;
        cout&lt;&lt;"Id"&lt;&lt;"\tCode"&lt;&lt;"\tCost"&lt;&lt;"\tAmount"&lt;&lt;"\tSubtotal"&lt;&lt;endl;
        cout&lt;&lt;"--------------------------------------------"&lt;&lt;endl;
        cout&lt;&lt;student_id&lt;&lt;setw(5)&lt;&lt;book_code&lt;&lt;setw(8)&lt;&lt;"$"&lt;&lt;book_cost&lt;&lt;
        setw(3)&lt;&lt;"$"&lt;&lt;tax_amount&lt;&lt;setw(4)&lt;&lt;"$"&lt;&lt;book_subtotal&lt;&lt;endl;
        cout&lt;&lt;endl;
        cout&lt;&lt;"Total number of books purchased:"&lt;&lt;setw(8)&lt;&lt;number_books&lt;&lt;endl;
        cout&lt;&lt;"Total books cost including tax:"&lt;&lt;setw(9)&lt;&lt;"$"&lt;&lt;total_book_cost&lt;&lt;endl;
        cout&lt;&lt;"Please enter your Student ID, then press enter."&lt;&lt;endl;
        cin&gt;&gt;student_id;
    }
    grand_total += total_book_cost;
    total_books_sold += number_books;
    cout&lt;&lt;"**************************************************"&lt;&lt;endl;
    cout&lt;&lt;"Grand Totals:"&lt;&lt;endl;
    cout&lt;&lt;"Total number of students who purchased books:"&lt;&lt;endl;
    cout&lt;&lt;"Total number of books sold:"&lt;&lt;endl;
    cout&lt;&lt;"Total cost of all books and taxes:"&lt;&lt;setw(9)&lt;&lt;"$"&lt;&lt;grand_total&lt;&lt;endl;

    //Can put grand totals here

    system("Pause");
    return 0;
}
</code></pre>
