Second Software engineering job

Source: Internet
Author: User
Tags switch loop

This homework for us these C # Whiteboard, it is indeed some difficult, this homework, I consulted some C # of the Great God just reluctantly completed. Here is my design interface,

The following is the code:

private void Button1_Click (object sender, EventArgs e)
{
Random a = new random ();
int B = A.next (1, 11);
int c = A.next (1, 11);
TextBox1.Text = convert.tostring (b);
TextBox2.Text = Convert.ToString (c);
TextBox3.Text = "";
Textbox4.text = "";
}

private void Button5_click (object sender, EventArgs e)
{

Switch (combobox1.text)
{
Case "+": Textbox4.text = convert.tostring (Convert.ToInt32 (TextBox1.Text) + Convert.ToInt32 (TextBox2.Text)); Break
Case "-": Textbox4.text = convert.tostring (Convert.ToInt32 (TextBox1.Text)-Convert.ToInt32 (TextBox2.Text)); Break
Case "*": Textbox4.text = convert.tostring (Convert.ToInt32 (TextBox1.Text) * Convert.ToInt32 (TextBox2.Text)); Break
Case "/": Textbox4.text = convert.tostring (Convert.ToInt32 (TextBox1.Text)/Convert.ToInt32 (TextBox2.Text)); Break
}
if (textbox3.text! = textbox4.text)
{
MessageBox.Show ("Please re-enter" if the answer does not match);
}
Else
{
MessageBox.Show ("answer right");
}
}

I also consulted the teacher, the teacher gave me some of his ideas, but I after thinking, or this simple, so with this,

"One" Code Analysis: Random number is used by the randomness, this our teacher has taught, very simple, the definition of two values, as the resulting random number, which I used a ComboBox as the operation symbol selection menu, and then use the switch loop to determine the operation symbol, and then to calculate, That's the approximate code. Hope the teacher Mingjian.

Second Software engineering job

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.