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