Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello C# programmers! I am learning C# and I am trying to better understand these concepts. Can someone show me how this code should be

Hello C# programmers! I am learning C# and I am trying to better understand these concepts. Can someone show me how this code should be written? I learn better by seeing the whole code and having someone comment the code with //, so that I know what each part of the code does. And steps for the design will help too. Can anyone help me? Thank you so much.

For this tutorial, you will create a simple Windows application that allows the user to enter two values and then select whether the application should add, subtract, multiply, or divide the input and output values that return back to the user.

The application must contain two textboxes, three labels, and four buttons. The first textbox should have a label that identifies it as the first number. The second textbox should have a label that identifies it as the second number (i.e., "Number 1", "Number 2").

Then, add four buttons. Each button should contain the text that describes its associated operation (i.e., "Add," "Subtract," "Multiply," or "Divide").

You should also have a label that displays the result the user performed.

Add event handlers so that when the user clicks the associated button, the program performs the required calculation. This is easy to do. Click on the button control in the form designer.

For example, if a user enters 1 in the "Number 1" textbox and 2 in the "Number 2" textbox the result .5 displays in the label. (Think about what type you should use to hold the value returned back to the user.)

For simplicity, only allow integers to be input into the number textboxes. Use the int.TryParse function to read the value from the textbox and convert it to an integer. If the TryParse function returns back false, then display a message box that states, "Please enter a valid number." (Hint: This can be done by using the MessageBox.Show() function.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions