Pair programming Project--arithmetic

Source: Internet
Author: User
Tags integer division

1. Companion information

Wang Yubong, ITCSC 13-1, school Number: 130201124

2. Basic functions

This assignment is arithmetic, is subtraction between the operation, popular simple.

3. Program 1) Form layout

2) Program operation

4. Code
Using System;Using System.Collections.Generic;Using System.ComponentModel;Using System.Data;Using System.Drawing;Using System.Linq;Using System.Text;Using System.Threading.Tasks;Using System.Windows.Forms;Namespace windowsformsapplication2{public partialClass Form1:form {PublicForm1() {InitializeComponent ();}PublicvoidIntegerdivide() {String Getmax = Textmin.text;int minnum = Convert.ToInt32 (Getmax);Minimum range setting String getmin = Textmax.text;int maxnum = Convert.ToInt32 (getmin);Maximum range setting Random R =New Random ();Take a random numberint Den1, Den2, NUM1, num2; Den1 = R.next (Minnum, maxnum); NUM1 = R.next (Minnum, DEN1); Den2 = R.next (Minnum, maxnum); num2 = R.next (Minnum, den2);if (den2! =0)List. Items.Add (Den1 +"/" +"(" + Den2 +")" +"=");else {List. Items.Add (Den2 +"/" +"(" + Den1 +")" +"="); } }PublicvoidFractionadd() {String Getmax = Textmin.text;int minnum = Convert.ToInt32 (Getmax); String getmin = Textmax.text;int maxnum = Convert.ToInt32 (getmin); Random R =New Random ();int Den1, Den2, NUM1, num2; Den1 = R.next (Minnum, maxnum); NUM1 = R.next (Minnum, DEN1); Den2 = R.next (Minnum, maxnum); num2 = R.next (Minnum, den2);if (den1! =0) {if (den2! =0) {List. Items.Add ("(" + NUM1 +"/" + Den1 +")" +"+" +"(" + num2 +"/" + Den2 +")" +"="); }Elseif (Den2 = =0) {List. Items.Add ("(" + NUM1 +"/" + Den1 +")" +"+" +"(" + Den2 +"/" + num2 +")" +"="); } }else {if (den2! =0) {List. Items.Add ("(" + Den1 +"/" + NUM1 +")" +"+" +"(" + num2 +"/" + Den2 +")" +"="); }Elseif (Den2 = =0) {List. Items.Add ("(" + Den1 +"/" + NUM1 +")" +"+" +"(" + Den2 +"/" + num2 +")" +"="); } } }PublicvoidFractiondelete() {String Getmax = Textmin.text;int minnum = Convert.ToInt32 (Getmax); String getmin = Textmax.text;int maxnum = Convert.ToInt32 (getmin); Random R =New Random ();int Den1, Den2, NUM1, num2; Den1 = R.next (Minnum, maxnum); NUM1 = R.next (Minnum, DEN1); Den2 = R.next (Minnum, maxnum); num2 = R.next (Minnum, den2);if (den1! =0) {if (den2! =0) {List. Items.Add ("(" + NUM1 +"/" + Den1 +")" +"-" +"(" + num2 +"/" + Den2 +")" +"="); }Elseif (Den2 = =0) {List. Items.Add ("(" + NUM1 +"/" + Den1 +")" +"-" +"(" + Den2 +"/" + num2 +")" +"="); } }else {if (den2! =0) {List. Items.Add ("(" + Den1 +"/" + NUM1 +")" +"-" +"(" + num2 +"-" + Den2 +")" +"="); }Elseif (Den2 = =0) {List. Items.Add ("(" + Den1 +"/" + NUM1 +")" +"-" +"(" + Den2 +"/" + num2 +")" +"="); } } }PublicvoidFractionmultiply() {String Getmax = Textmin.text;int minnum = Convert.ToInt32 (Getmax); String getmin = Textmax.text;int maxnum = Convert.ToInt32 (getmin); Random R =New Random ();int Den1, Den2, NUM1, num2; Den1 = R.next (Minnum, maxnum); NUM1 = R.next (Minnum, DEN1); Den2 = R.next (Minnum, maxnum); num2 = R.next (Minnum, den2);if (den1! =0) {if (den2! =0) {List. Items.Add ("(" + NUM1 +"/" + Den1 +")" +"*" +"(" + num2 +"/" + Den2 +")" +"="); }Elseif (Den2 = =0) {List. Items.Add ("(" + NUM1 +"/" + Den1 +")" +"*" +"(" + Den2 +"/" + num2 +")" +"="); } }else {if (den2! =0) {List. Items.Add ("(" + Den1 +"/" + NUM1 +")" +"*" +"(" + num2 +"/" + Den2 +")" +"="); }Elseif (Den2 = =0) {List. Items.Add ("(" + Den1 +"/" + NUM1 +")" +"*" +"(" + Den2 +"/" + num2 +")" +"="); } } }PublicvoidFractiondivide() {String Getmax = Textmin.text;int minnum = Convert.ToInt32 (Getmax); String getmin = Textmax.text;int maxnum = Convert.ToInt32 (getmin); Random R =New Random ();int Den1, Den2, NUM1, num2; Den1 = R.next (Minnum, maxnum); NUM1 = R.next (Minnum, DEN1); Den2 = R.next (Minnum, maxnum); num2 = R.next (Minnum, den2);if (den1! =0) {if (den2! =0) {List. Items.Add ("(" + NUM1 +"/" + Den1 +")" +"/" +"(" + num2 +"/" + Den2 +")" +"="); }Elseif (Den2 = =0) {List. Items.Add ("(" + NUM1 +"/" + Den1 +")" +"/" +"(" + Den2 +"/" + num2 +")" +"=");Change}}else {if (den2! =0) {List. Items.Add ("(" + Den1 +"/" + NUM1 +")" +"/" +"(" + num2 +"/" + Den2 +")" +"="); }Elseif (Den2 = =0) {List. Items.Add ("(" + Den1 +"/" + NUM1 +")" +"/" +"(" + Den2 +"/" + num2 +")" +"="); } } }PrivatevoidForm1_Load(object sender, EventArgs e) { }PrivatevoidButton1_Click(object sender, EventArgs e) {String getnum = Textin.text;int num = Convert.ToInt32 (getnum);Enter the number of topics String Getmax = Textmin.text;int minnum = Convert.ToInt32 (Getmax);Minimum number set String getmin = Textmax.text;int maxnum = Convert.ToInt32 (getmin);Maximum number settingint i; Random R =New Random ();int import =0;for (i =0; i < num; i++) {int Den1, Den2, NUM1, num2; Den1 = R.next (Minnum, maxnum); NUM1 = R.next (Minnum, DEN1); Den2 = R.next (Minnum, maxnum); num2 = R.next (Minnum, den2); Import = R.next (0,8);Switch (import) {Case0:List. Items.Add (Den1 +"+" +"(" + Den2 +")" +"=");BreakCase1:List. Items.Add (Den1 +"-" +"(" + Den2 +")" +"=");BreakCase2:List. Items.Add (Den1 +"*" +"(" + Den2 +")" +"=");break; case 3:integerdivide (); break; //integer division case 4:fractionadd (); Span class= "Hljs-keyword" >break; //score addition case 5:fractiondelete (); Span class= "Hljs-keyword" >break; //fractional subtraction case 6:fractionmultiply () ; break; //fractional multiplication case 7:fractiondivide (); Span class= "Hljs-keyword" >break; //fractional Division}} }}} 
5. Summary
Through these hours of learning, as well as teachers and teaching assistants carefully taught, I technology leaps and bounds, thanks to the teacher TA and students guidance!

Pair programming Project--arithmetic

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.