# Adding up all the numbers in the list...

• 06-04-2003
Grayson_Peddie
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...