C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-04-2003, 11:57 AM   #1
Registered User
 
Grayson_Peddie's Avatar
 
Join Date: May 2002
Posts: 96
Adding up all the numbers in the list...

Hi, there. I have a question for you. How will I be able to add up all the numbers depending on which symbols were used (whether it be a plus, a minus, multiply, or divide)? When the equal had been checked and if I press add, the equal sign will add it to the symbol list and then it will go from the first item, then look at the first symbol in the symbol list. Then, it will look at the second item and then look for the second symbol and then iff there's an equal sign, it will either add, subtract, multiply, or divide depending on what's on the symbols list. Then, once it is done, it will add to the SubDisplay, which the answer will show up in the upper-right hand corner of a dialog box. This can be the same for the percent sign; however, AFAIK, the percent sign divides the last item by 100 and then display the answer.

Here's an example of how it works.

20 + 5 * 2 / 5 + 100 * 4 ... (and so on until the user selects equal and then press add, then the calculator will do the process as mentioned (for example: 20 + 5 * 2 / 5 + 100 * 4 =).

Here's the code that I'm trying to do:

Code:
		private void Add_Click(object sender, System.EventArgs e)
		{
			numbers = Decimal.Parse(MainDisplay.Text);
			TrackingDisplay.Items.Add(numbers.ToString());
			if(P.Checked == true) 
			{
				SymbolList.Items.Add(plus.ToString());
			}
			if(S.Checked == true) 
			{
				SymbolList.Items.Add(minus.ToString());
			}
			if(M.Checked == true) 
			{
				SymbolList.Items.Add(multiply.ToString());
			}
			if(D.Checked == true) 
			{
				SymbolList.Items.Add(divide.ToString());
			}
			if(D100.Checked == true) 
			{
				SymbolList.Items.Add(percent.ToString());
			}
			if(E.Checked == true)
			{
				SymbolList.Items.Add(equals.ToString());
				decimal[] totalfromtracking = TrackingDisplay.Items.CopyTo(0,0);
				for(int i = 0; i <= totalfromtracking; i++) {
				
			}
			
		}
Look at the one that says:

Code:
if(E.Checked == true)
As you can see, I am just trying to figure it out how the program will add/subtract/multiply/divide depending on what symbols were selected and how many items were in the tracking list.

For example:

8
5
10
23
7
9
...and so on...

Thanks for your time reading my post!
-Grayson
__________________
View in Braille.
http://www.future-gpnet.com/braille.jpg

Like a bolt out of the BLUE,
Fate steps up and sees you THROUGH,
When you wish upon a STAR
YOUR DREAMS COME TRUE.
Grayson_Peddie is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unknown memory leak with linked lists... RaDeuX C Programming 6 12-07-2008 04:09 AM
Pleas take a look & give a critique sh3rpa C++ Programming 14 10-19-2007 10:01 PM
link list Unregistered C++ Programming 4 12-13-2001 05:41 AM
1st Class LIST ADT Unregistered C++ Programming 1 11-09-2001 07:29 PM
singly linked list clarinetster C Programming 2 08-26-2001 10:21 PM


All times are GMT -6. The time now is 02:03 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22