help for if else

i just write for a small code for the homework, there is a part of if, else statement. but there are a problem. once, I type right stock name, and numbers to buy, it will show "wrong numbers to buy"

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

   for (int m=0; m<j; ++m)
            {cout<<"the current stocks in the system: "<<stockArray[m].getCompanyName()<<" "<<stockArray[m].getTradingTicker()<<endl;

            }
       cout<<"please type which stock do you want to buy"<<endl;
       string wantstocks;
       cin>>wantstocks;
       for(int m=0; m<j; ++m)
           {
               if (stockArray[m].getCompanyName()==wantstocks||stockArray[m].getTradingTicker()==wantstocks)
               {   // int& x=m;
				   cout<<"how many shares do you want to buy? please enter the number to buy: ";
			   //}
			  // else
				//   cout<<"wrong ticker"<<endl;
                   int number2;
                   cin>>number2;
                   if( (number2>0)&& (number2*(stockArray[m].getSharePrice())<my.getFundsAvailabe()))
                   {
                     stockArray[m].setNumberOfShares(stockArray[m].getNumberOfShares()-number2);
                     my.setFundsAvailabe( my.getFundsAvailabe()-(number2*(stockArray[m].getSharePrice() ) ) ) ;
                   }
				  else 
					  cout<<"wrong number to buy"<<endl;
              }
                   else
                   cout<<"wrong ticker or company to buy";

               }
}



if any one help me, i can send the code to you
Topic archived. No new replies allowed.