標題:
[4-7]進階計算機
[打印本頁]
作者:
李泳霖
時間:
2023-11-22 11:36
標題:
[4-7]進階計算機
using static System.Formats.Asn1.AsnWriter;
double num1, num2;
string oper;
re:
System.Console.Write("請輸入第一個數:");
num1 = System.Convert.ToDouble(System.Console.ReadLine());
System.Console.Write("請輸入要做的運算(+、-、*、/) : ");
oper= System.Console.ReadLine();
System.Console.Write("請輸入第二個數:");
num2 = System.Convert.ToDouble(System.Console.ReadLine());
if (oper == "+")
System.Console.WriteLine(num1 + " + " + num2 + " = " + (num1 + num2));
else if (oper == "-")
System.Console.WriteLine(num1 + " - " + num2 + " = " + (num1 - num2));
else if (oper == "*")
System.Console.WriteLine(num1 + " * " + num2 + " = " + (num1 * num2));
else if (oper == "/")
System.Console.WriteLine(num1 + " / " + num2 + " = " + (num1 / num2));
else
System.Console.WriteLine("不合法的運算符號");
goto re;
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2