作業四 結對程式設計專案 四則運算 1

2022-09-01 21:36:21 字數 4919 閱讀 9429

這次的作業對我來說難度很大,所以必須要借助於網上的知識來進行補充,通過上網查資料,結合上課老師所講的內用,還有老師所給-出的一些經典的範例,最重要的是結合我自己原有的知識來進行補充,我終於還是做出了一些成品,但是我最初完成的不能實現,所以這讓我困擾了好久,但是,我經過看到了網上的一些源**,認真學習了之後,才借鑑了過來,要理解才能成為自己的東西!但是,目前只能實現整數的四則運算!

namespace 計算器

public partial class form1 : form

public form1()

initializecomponent();

public string num;

public int flag;//用於判斷輸入的操作符

public double num1, num2;

private void num0_button_click(object sender, eventargs e)

num = num + "0";

num2 = convert.todouble(num);

textbox.text = num;

private void num1_button_click(object sender, eventargs e)//重點演算法1

if (textbox.text == "0")

num = "1";

textbox.text = convert.tostring(num);

else

num = num + "1";

num2 = convert.todouble(num);

textbox.text = num;

private void num2_button_click(object sender, eventargs e)

if (textbox.text == "0")

num = "2";

textbox.text = convert.tostring(num);

else

num = num + "2";

num2 = convert.todouble(num);

textbox.text = num;

private void num3_button_click(object sender, eventargs e)

if (textbox.text == "0")

num = "3";

textbox.text = convert.tostring(num);

else

num = num + "3";

num2 = convert.todouble(num);

textbox.text = num;

private void num4_button_click(object sender, eventargs e)

if (textbox.text == "0")

num = "4";

textbox.text = convert.tostring(num);

else

num = num + "4";

num2 = convert.todouble(num);

textbox.text = num;

private void num5_button_click(object sender, eventargs e)

if (textbox.text == "0")

num = "5";

textbox.text = convert.tostring(num);

else

num = num + "5";

num2 = convert.todouble(num);

textbox.text = num;

private void num6_button_click(object sender, eventargs e)

if (textbox.text == "0")

num = "6";

textbox.text = convert.tostring(num);

else

num = num + "6";

num2 = convert.todouble(num);

textbox.text = num;

private void num7_button_click(object sender, eventargs e)

if (textbox.text == "0")

num = "7";

textbox.text = convert.tostring(num);

else

num = num + "7";

num2 = convert.todouble(num);

textbox.text = num;

private void num8_button_click(object sender, eventargs e)

if (textbox.text == "0")

num = "8";

textbox.text = convert.tostring(num);

else

num = num + "8";

num2 = convert.todouble(num);

textbox.text = num;

private void num9_button_click(object sender, eventargs e)

if (textbox.text == "0")

num = "9";

textbox.text = convert.tostring(num);

else

num = num + "9";

num2 = convert.todouble(num);

textbox.text = num;

private void add_button_click(object sender, eventargs e)//重點演算法2

if (textbox.text.length > 0)

num1 = convert.todouble(textbox .text);

num = "";

flag = 1;

textbox.text = "";

textbox.focus();

private void dev_button_click(object sender, eventargs e)

if (textbox.text.length > 0)

num1 = convert.todouble(textbox.text);

num = "";

flag = 2;

textbox.text = "";

textbox.focus();

private void mul_button_click(object sender, eventargs e)

if (textbox.text.length > 0)

num1 = convert.todouble(textbox.text);

num = "";

flag = 3;

textbox.text = "";

textbox.focus();

private void chu_button_click(object sender, eventargs e)

if (textbox.text.length > 0)

num1 = convert.todouble(textbox.text);

num = "";

flag = 4;

// textbox.text = "";

textbox.focus();

private void equ_button_click(object sender, eventargs e)

switch (flag)

case 1:

textbox.text = convert.tostring(num1+convert .todouble(num));//重點演算法3

num2 = convert.todouble(textbox .text);

break;

case 2:

textbox.text = convert.tostring(num1 - convert.todouble(num));

num2 = convert.todouble(textbox.text);

break;

case 3:

textbox.text = convert.tostring(num1 * convert.todouble(num));

num2 = convert.todouble(textbox.text);

break;

case 4:

textbox.text = convert.tostring(num1 / convert.todouble(num));

num2 = convert.todouble(textbox.text);

break;

private void re_button_click(object sender, eventargs e)

num = "";

textbox.text = "0";

作業四 結對程式設計專案 四則運算

經過一段時間的學習和查閱資料,我跟小夥伴終於完成了這項任務,雖然過程磕磕絆絆,但最終還是把程式除錯了出來。下面是我的 c namespace szys1 public static int count 0 public static int right 0 public static int fau...

作業四 結對程式設計專案 四則運算

這是王珏的部落格,程式 和截圖在上面的 鏈結中 1.小組成員 王乃寬 130201113 宋宇輝 130201112 合作小組 王珏 130201128 杜堯 130201204 宋玉輝 優點 願意去學習,耐心好。缺點 基礎比較差,上手慢一些。杜堯 優點 學的比較快,實際操作還不錯。缺點 基礎比較差...

作業四 結對程式設計專案 四則運算

一 基本要求 1 實現乙個帶有使用者介面的四則運算。2 生成的題目不能重複。3 支援負數,例如 1,1 2,3 4 5等。4 題目的數量 個人專案的要求 5 數值的範圍 6 題目中最多幾個運算子 7 題目中是否有乘除法 8 題目中或運算過程中有無負數 根據老師的要求我們做的程式中解決了以上的問題。因...