Title: Please write a "software" that can automatically generate primary arithmetic topics. Allow the program to accept the user to enter the answer, and determine the right and wrong. Finally, the total number of pairs/errors is given.
Requirements Analysis: Basic functions, can meet the user to complete a simple addition, subtraction, multiplication, except operation, each calculation can be counted the number of times, the user gives the answer, can with
Computer answer match, error and correct will appear the corresponding prompt box!
Design: Using VS2010 as a platform, written in C # language, with a global variable to record the number of operations, the rest are written with the corresponding control properties, pay special attention to the relationship between shaping and character type, the use if statement for each of the possible choices!
Code implementation:
UsingSystem;UsingSystem.Collections.Generic;UsingSystem.ComponentModel;UsingSystem.Data;UsingSystem.Drawing;UsingSystem.Linq;UsingSystem.Text;UsingSystem.Windows.Forms;Namespacewindowsformsapplication1{PublicPartialClassForm1:form {PublicForm1 () {InitializeComponent ();}Privatevoid Domainupdown1_selecteditemchanged (Objectsender, EventArgs e) {}int s =0;Privatevoid Button1_Click (Objectsender, EventArgs e) {if (TextBox1.Text = =null | | TextBox2.Text = =null | | TextBox3.Text = =Null) {MessageBox.Show ("Calculate the number and the answer you fill cannot be empty"); }Else{s = s +1; Label6. Text =S.tostring ();IntA, B;IntC A =Int32.Parse (TextBox1.Text); b =Int32.Parse (TextBox2.Text);if (Combobox1.text = ="Add") {c = a + b; textbox3.text =C.tostring (); }if (Combobox1.text = ="Reducing") {c = a-B; textbox3.text =C.tostring (); }if (Combobox1.text = ="By") {c = a * b; textbox3.text =C.tostring (); }if (Combobox1.text = ="Except") {c = A/b; textbox3.text =C.tostring (); }if (TextBox3.Text = =Textbox4.text) {label4. Text ="Congratulations, calculate right!!!!"; }else {label4. Text ="Sorry, the answer is wrong!!!"; } } }Privatevoid Label2_click (Object sender, EventArgs e) {} private void Form1_Load ( object sender, EventArgs e) {} private void button2_click (object sender, EventArgs e) {TextBox1.Text = ; TextBox3.Text = ; Textbox4.text = ; Combobox1.text = ; Label6. Text =
Program run:
Analysis and Summary: This operation is too simple, because I did not do mixed operation, resulting in the program is not very difficult, but through this study, I will continue to improve it!
PSP time-consuming statistics: