Question: I could really use some help with this porblem Must be form application in C# please make solution very simple as I am a beginner

I could really use some help with this porblem

Must be form application in C# please make solution very simple as I am a beginner

-------------------------------------------------------------------------------------------------------------------------------------------------------

In this exercise, youll add data validation to the Simple Calculator form of extra exercise A5-E1.

1.Open the SimpleCalculator project in the Assignment5\SimpleCalculatorValidation directory.

2. Code methods named

IsPresent,

IsDecimal, and

IsWithinRange

that work like the methods described in Murachs chapter 7 of the book.

3. Code a method named IsOperator that checks that the text box thats passed to it contains a value of +, -, *, or /.

4. Code a method named IsValidData that checks that the Operand 1 and Operand 2 text boxes contain a decimal value between 0 and 1,000,000 (non-inclusive) and that the Operator text box contains a valid operator.

5. Delete all of the catch blocks from the try-catch statement in the btnCalculate_Click event handler except for the one that catches any exception. Then, add code to this event handler that performs the calculation and displays the result only if the values of the text boxes are valid.

6. Test the application to be sure that all the data is validated properly.

The Code that needs to be modified( remember it is a form application) picture of form are below

I could really use some help with this porblem Must be form

application in C# please make solution very simple as I am a

The code that must be modified

private void btnCalculate_Click(object sender, EventArgs e) { decimal operand1 = Convert.ToDecimal(txtOperand1.Text); string operator1 = txtOperator.Text; decimal operand2 = Convert.ToDecimal(txtOperand2.Text); decimal result = Calculate(operand1, operator1, operand2);

result = Math.Round(result, 4); this.txtResult.Text = result.ToString(); txtOperand1.Focus(); }

private decimal Calculate(decimal operand1, string operator1, decimal operand2) { decimal result = 0; if (operator1 == "+") result = operand1 + operand2; else if (operator1 == "-") result = operand1 - operand2; else if (operator1 == "*") result = operand1 * operand2; else if (operator1 == "/") result = operand1 / operand2; return result; }

private void btnExit_Click(object sender, EventArgs e) { this.Close(); } } }

Thanks

a Simple Calculator X Operand 1 86 Operator: Operand 2 11.11 7.7408 Result: Calculate

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!