Click here to Skip to main content
16,012,843 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: any other chinese programmer in USA ? Pin
AnonymousBabe@usa.net5-Feb-02 17:32
AnonymousBabe@usa.net5-Feb-02 17:32 
GeneralCaret and MDI View Pin
AnonymousBabe@usa.net5-Feb-02 14:15
AnonymousBabe@usa.net5-Feb-02 14:15 
GeneralSetting up CListView Properties Pin
Aaron Schaefer5-Feb-02 12:07
Aaron Schaefer5-Feb-02 12:07 
GeneralRe: Setting up CListView Properties Pin
Derek Waters5-Feb-02 12:17
Derek Waters5-Feb-02 12:17 
GeneralRe: Setting up CListView Properties Pin
Aaron Schaefer5-Feb-02 12:29
Aaron Schaefer5-Feb-02 12:29 
GeneralRe: Setting up CListView Properties Pin
Michael Dunn5-Feb-02 13:09
sitebuilderMichael Dunn5-Feb-02 13:09 
Generalchecking first char input be4 reading the rest Pin
5-Feb-02 10:18
suss5-Feb-02 10:18 
Generalhere is my code Pin
5-Feb-02 10:24
suss5-Feb-02 10:24 
    char ch;
	do
	{  cin>> ch;
  			//Here I check the first Letter of The Input
			//And Do whatever is necessary to process it
   			switch (ch)
			{
				//***********************************************************************************
				case 'C':
				{
                    cin>>tempST>>tempIV;
                    tempStock->setStockTicker(tempST);
                    int low =0, mid,  high=14;
		    		while (low <= high)
					{
						mid = (low + high)/2;
      		     		(*tempStock) = tempStocks->getStock(mid);
                        tempStock->setcurStockPrice(tempIV);
    					if (strcmp(tempStock->getStockTicker(),inputLine ) < 0)
						low = mid + 1;
						else if (strcmp(tempStock->getStockTicker(),inputLine ) > 0)
						high= mid - 1;
						else
						mid = mid;						
                    
					}
      
				}break;

				//***********************************************************************************
                case 'B':
				{
					count = 0;
				    while((c = cin.get()) != ' ')
					{
						inputLine[count] = c;
		                count++;
					}
			        inputLine[count] = '\0'; //input line is storing the SS# here
					count = 0;   

					//Here starts my binary search again
                    int tempAccount;
				    int low =0, mid,  high=14; 
		    		while (low <= high)
					{
						mid = (low + high)/2;
						// here i create a temporary investor to hold data of Buyer
			     		Investor tempInvestor = (*tempInvestors).getInvestor(mid);
                        tempAccount = tempInvestor.getAccountBalance(); //AccountBalance Of Buyer
    					if (strcmp(tempInvestor.getSocialSecurity(),inputLine ) < 0)
						low = mid + 1;
						else if (strcmp(tempInvestor.getSocialSecurity(),inputLine ) > 0)
						high= mid - 1;
						else
					    mid = mid;
					}
														
				    while((c = cin.get()) != ' ')
					{
						inputLine[count] = c;
		                count++;
					}
			        inputLine[count] = '\0'; 
			        count = 0; 
							
                    char tempTicker[30];
					strcpy(tempTicker,inputLine); // now tempTicker stores the tickerSymbol

                    // Here i'm performing another binary search to look for the 
					// specific stock that has that same stockTicker
					int lo =0, mi,  hi=14; 
					int tempStockPrice;
		    		while (lo <= hi)
					{
						mi = (lo + hi)/2;
			            *tempStock = (*tempStocks).getStock(mi);
                        tempStockPrice = (*tempStock).getCurStockPrice(); // storing the stockprice in tempStockPrice
                		if (strcmp((*tempStock).getStockTicker(),inputLine ) < 0)
					    lo = mi + 1;
					    else if (strcmp((*tempStock).getStockTicker(),inputLine ) > 0)
					    hi = mi - 1;
						else
						mi = mi;	                   
					}
							

					while((c = cin.get()) != '\n ')
					{
						inputLine[count] = c;
		                count++;
					}
			        inputLine[count] = '\0'; 
			        count = 0; 
					int tempNumShares = atoi (inputLine);  //tempInt is storing number of shares now.
					//LATER;;;;;;;;;;;;IF YOU HAVE ANY PROBLEM WITH THE VALUES OF TEMPSTOCKPRICE AND TEMPNUMSHARES LOOK FOR ANOTHER WAY TO DECLARE THOSE TWO VARIABLES OUT OF THE LOOP.
					if ( tempAccount >= (tempStockPrice * tempNumShares)) 
					{
					    (*tempTickerShare).setNumOfShares(tempNumShares);	
						(*tempTickerShare).setTickerSymbol(tempTicker);
						(*tempInvestor).addTickerShare(tempTickerShare);
					}
					

				}break;

				//***********************************************************************************
                case 'S':
				{
					while((c = cin.get()) != ' ')
					{
						inputLine[count] = c;
		                count++;
					}
			        inputLine[count] = '\0'; //input line is storing the SS# here
					count = 0;   

					//Here starts my binary search again
                    int low =0, mid,  high=14; 
		    		while (low <= high)
					{
						mid = (low + high)/2;
						// here i create a temporary investor to hold data of Seller
			     		Investor tempInvestor = (*tempInvestors).getInvestor(mid);
                        if (strcmp((tempInvestor).getSocialSecurity(),inputLine ) < 0)
						low = mid + 1;
						else if (strcmp((tempInvestor).getSocialSecurity(),inputLine ) > 0)
						high= mid - 1;
						else
					    mid = mid;
					}

					while((c = cin.get()) != ' ')
					{
						inputLine[count] = c;
		                count++;
					}
			        inputLine[count] = '\0'; 
			        count = 0; 
							
                    char tempTicker[30];
					strcpy(tempTicker,inputLine); // now tempTicker stores the tickerSymbol
                    int lo =0, mi,  hi=14;
					while (lo <= hi)
					{
						mi = (lo + hi)/2;
			            tempTickerShare = (*tempInvestor).getTickerShare(mi);
						strcpy (tempTicker , (*tempTickerShare).getTickerSymbol());
                        if (strcmp(tempTicker,inputLine ) < 0)
					    lo = mi + 1;
					    else if (strcmp(tempTicker,inputLine ) > 0)
					    hi = mi - 1;
						else
						mi = mi;	                   
					}

					while((c = cin.get()) != '\n')
					{
						inputLine[count] = c;
		                count++;
					}
			        inputLine[count] = '\0'; 
			        count = 0; 
					int tempNumShares = atoi (inputLine);  
					
					//Here i check whether the investor has enough shares to sell
					if (tempNumShares <= (*tempTickerShare).getNumOfShares()) 
					{
						tempNumShares = (*tempTickerShare).getNumOfShares() - tempNumShares;
						(*tempTickerShare).setNumOfShares(tempNumShares);
					}
					else
						cout<< "Sorry don't have enough shares to sell"<<endl;
 
="" }break;
="" }

="" }
="" while="" (!cin.eof());
<\pre="">

GeneralDebugging Pin
Paul M Watt5-Feb-02 13:21
mentorPaul M Watt5-Feb-02 13:21 
GeneralRe: Debugging Pin
5-Feb-02 16:21
suss5-Feb-02 16:21 
GeneralRe: Debugging Pin
Christian Graus5-Feb-02 18:43
protectorChristian Graus5-Feb-02 18:43 
GeneralRe: Debugging Pin
Paul M Watt5-Feb-02 19:45
mentorPaul M Watt5-Feb-02 19:45 
GeneralRe: Debugging Pin
5-Feb-02 20:59
suss5-Feb-02 20:59 
GeneralTemplate specialization Pin
User 98855-Feb-02 9:55
User 98855-Feb-02 9:55 
GeneralRe: Template specialization Pin
Joaquín M López Muñoz5-Feb-02 10:11
Joaquín M López Muñoz5-Feb-02 10:11 
GeneralRe: Template specialization Pin
User 98855-Feb-02 10:36
User 98855-Feb-02 10:36 
GeneralRe: Template specialization Pin
Joaquín M López Muñoz5-Feb-02 10:41
Joaquín M López Muñoz5-Feb-02 10:41 
GeneralRe: Template specialization Pin
User 98855-Feb-02 12:29
User 98855-Feb-02 12:29 
GeneralRe: Template specialization Pin
User 98855-Feb-02 10:34
User 98855-Feb-02 10:34 
Generalhere is the input i'm having trouble reading Pin
5-Feb-02 8:49
suss5-Feb-02 8:49 
GeneralRe: thank you but... Pin
Joaquín M López Muñoz5-Feb-02 9:14
Joaquín M López Muñoz5-Feb-02 9:14 
GeneralRe: thank you but... Pin
5-Feb-02 9:55
suss5-Feb-02 9:55 
GeneralRe: thank you but... Pin
Christian Graus5-Feb-02 9:57
protectorChristian Graus5-Feb-02 9:57 
GeneralRe: thank you but... Pin
5-Feb-02 10:15
suss5-Feb-02 10:15 
GeneralRe: thank you but... Pin
Christian Graus5-Feb-02 10:33
protectorChristian Graus5-Feb-02 10:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.