// Button / private void BtnDivision_Click(object sender, RoutedEventArgs e) { if (TbInputNumbers.Text != "0") { //Progress of the calculation's text TbCalculationProgress.Text += TbInputNumbers.Text; if (NewCalculation == true) { //Converting the Current number which is inside the TbInputNumbers TextBlock //Adding the Current number to the Memory array, incrementing the Memory array's index counter by one CurrentNumber = Convert.ToDouble(TbInputNumbers.Text); Calculations.AddToMemory(CurrentNumber); Calculations.IncrementMemoryIndexByOne(); UserCanDeleteLastNumber = true; } //if this is inside the program, then the multiple calculation part does not work //Replacing the CurrentNumber part works more effectively and it is easire to understand //Calculations.IncrementMemoryIndexByOne(); //Checking if there is a new calculation in progress or not //Converting the Current number which is inside the TbInputNumbers TextBlock //Adding the Current number to the Memory array, incrementing the Memory array's index counter by one //Storing the calculation in the result variable (Rounding the result) //Showing the user the given result in the TbResultmemory textBlock //Adding the result to the Memory array, incrementing the Memory array's index counter by one if (NewCalculation == false) { CurrentNumber = Convert.ToDouble(TbInputNumbers.Text); Calculations.AddToMemory(CurrentNumber); Result = Calculations.Division(); Math.Round(Result, 10); TbResultMemory.Text = Result.ToString(); Calculations.AddToMemory(Result); Calculations.IncrementMemoryIndexByOne(); NewCalculation = true; UserCanDeleteLastNumber = false; } } else if (TbInputNumbers.Text == "0") { double MostRecentlyAddedResult = Calculations.GiveBackMostRecentValueOfResultMemory(); //Checking whether the memory has been cleared or not //Progress of the calculation's text if (MemoryHasBeenCleared == true) { TbCalculationProgress.Text += MostRecentlyAddedResult.ToString(); MemoryHasBeenCleared = false; } //Increment the index by one as we are not calculating but waiting for a new input //(if this is not here then the result STEP of the Memory array will always change to the new input) Calculations.IncrementMemoryIndexByOne(); } //We add the button's text to the TbCalculationProgress textblock TbCalculationProgress.Text += "/"; //After the calculation this variable will always be one CalculationIsOnGoing = 1; //Setting the TbInputNumbers Textblock's text to default after every calculation TbInputNumbers.Text = "0"; }