C++ Primer Exercise 2.41
<p>I need your help guys i'm stack at 1 exercise witch was at the end of the chapter 2 !  My problem with this exercise is that i can't figure out how to make logically loop to ask several times the input ! I wrote the code witch ask twice for the input ! Previously with book provided header i did that task easy but that way didn't work anymore . So ill give you the exercise and code and hope you can help me. And sorry for my Englsih</p>

<p><strong>Exercise</strong><br>
Write program witch will have a class in same place where you <code>main</code> function.<br>
Write Code witch will read several transaction with same Book Number and count each  transaction with that book number.</p>

<p><strong>My Code</strong>  </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

//Data structure Code 
struct Sales_Data
{
std::string bookNo;
unsigned unit_sold;
double revenue;
};
int main()
{

Sales_Data data1,data2; //Data wich will hold input 
double price;           //Price per book used to calculate total revenue

// Checking if there was data input of book number units sold and price
if (std::cin&gt;&gt;data1.bookNo&gt;&gt;data1.unit_sold&gt;&gt;price)
{
    int cnt=1;  //Start Counter 
    data1.revenue=data1.unit_sold*price;// data1 calculating total revenue from price and unit_sold 

    while (std::cin&gt;&gt;data2.bookNo&gt;&gt;data2.unit_sold&gt;&gt;price)
    {
        data2.revenue=data2.revenue*price;

              //checking if book name is same
        if (data1.bookNo == data2.bookNo)
        {
            ++cnt; //Incrementing counter if they same
            unsigned totalCnt=data1.unit_sold+data2.unit_sold;
            double totalRevenue=data1.revenue+data2.revenue;
            //Print out result
            std::cout&lt;&lt;cnt&lt;&lt;data1.bookNo&lt;&lt;" "&lt;&lt;totalCnt&lt;&lt;" "&lt;&lt;totalRevenue&lt;&lt;" ";
            getchar();
            getchar();
            getchar();
            if (totalCnt != 0)

                std::cout&lt;&lt;totalCnt/totalRevenue;
            else 
                std::cout&lt;&lt;"(No Sales)"&lt;&lt;std::endl;
                return 0;
        }else{
            std::cerr&lt;&lt;"Book numbers isn't same"&lt;&lt;std::endl;
            return -1;
        }           
    }
}
return 0;          
}   
</code></pre>

<p>And also wast sure why but the <strong>revenue</strong> gives me garbage number.
Thank you for your time.</p>
