private void Btnfake(string FakSwitch) { switch (FakSwitch) { case "/": Result = (Num1 / Num2).ToString(); break; case "X": Result = (Num1 * Num2).ToString(); break; case "-": Result = (Num1 - Num2).ToString(); break; case "+": Result = (Num1 + Num2).ToString(); break; } AnswerAdapter.Add(Result); Toast.MakeText(this, "The Result is " + Result, ToastLength.Long).Show(); string tag = "Log"; Log.Info(tag, Num1.ToString()); Log.Info(tag, Num2.ToString()); Log.Info(tag, Result); }
private void btnEquals_Click(object sender, EventArgs e) { Num2 = decimal.Parse(txtdisply.Text); switch (Operation) { case "+": txtdisply.Text = (Num1 + Num2).ToString(); break; case "-": txtdisply.Text = (Num1 - Num2).ToString(); break; case "x": txtdisply.Text = (Num1 * Num2).ToString(); break; case "/": txtdisply.Text = (Num1 / Num2).ToString(); break; case "^": txtdisply.Text = (int.Parse(Num1.ToString()) ^ int.Parse(Num2.ToString())).ToString(); break; case "%": txtdisply.Text = (Num1 % Num2).ToString(); break; } }
/// <summary> /// 100以内3个数的加减法运算 /// </summary> /// <returns>算式</returns> public string Expression1003() { if (CaseNum1 == 0) { if (CaseNum2 == 0) { if (this.Num1 + this.Num2 + this.Num3 <= 100) { return(Num1.ToString() + "+" + Num2.ToString() + "+" + Num3.ToString()); } else { return(null); } } else { if (this.Num1 + this.Num2 - this.Num3 <= 100 && this.Num1 + this.Num2 - this.Num3 >= 0) { return(Num1.ToString() + "+" + Num2.ToString() + "-" + Num3.ToString()); } else { return(null); } } } else { if (CaseNum2 == 0) { if (this.Num1 - this.Num2 >= 0 && this.Num1 - this.Num2 + this.Num3 <= 100) { return(Num1.ToString() + "-" + Num2.ToString() + "+" + Num3.ToString()); } else { return(null); } } else { if (this.Num1 - this.Num2 - this.Num3 >= 0) { return(Num1.ToString() + "-" + Num2.ToString() + "-" + Num3.ToString()); } else { return(null); } } } }
private void btn4_Click(object sender, RoutedEventArgs e) { if (Operation == "") { Num1 = (Num1 * 10) + 4; txtResult.Text = Num1.ToString(); } else { Num2 = (Num2 * 10) + 4; txtResult.Text = Num2.ToString(); } }
private void btnNegative_Click(object sender, RoutedEventArgs e) { if (Operation == "") { Num1 *= -1; txtResult.Text = Num1.ToString(); } else { Num2 *= -1; txtResult.Text = Num2.ToString(); } }
/// <summary> /// 100以内2个数的加减法运算 /// </summary> /// <returns>算式</returns> public string Expression1002() { if (this.Num1 + this.Num2 <= 100) { return(Num1.ToString() + "+" + Num2.ToString()); } else if (this.Num1 - this.Num2 >= 0) { return(Num1.ToString() + "-" + Num2.ToString()); } else { return(Num2.ToString() + "-" + Num1.ToString()); } }
private void Btndivide_Click(object sender, System.EventArgs e) { Num1 = Convert.ToDouble(txtNum1.Text); Num2 = Convert.ToDouble(txtNum2.Text); // Result = Num1 / Num2; string result = (Num1 + " / " + Num2 + " = " + Result); Toast.MakeText(this, "The Result is " + Result, ToastLength.Long).Show(); string tag = "Divide"; Log.Info(tag, Num1.ToString()); Log.Info(tag, Num2.ToString()); Log.Info(tag, result); }
public override string ToString() { var sb = new StringBuilder("Work("); int tmp1 = 0; if (__isset.num1) { if (0 < tmp1++) { sb.Append(", "); } sb.Append("Num1: "); Num1.ToString(sb); } if (__isset.num2) { if (0 < tmp1++) { sb.Append(", "); } sb.Append("Num2: "); Num2.ToString(sb); } if (__isset.op) { if (0 < tmp1++) { sb.Append(", "); } sb.Append("Op: "); Op.ToString(sb); } if ((Comment != null) && __isset.comment) { if (0 < tmp1++) { sb.Append(", "); } sb.Append("Comment: "); Comment.ToString(sb); } sb.Append(')'); return(sb.ToString()); }
public override string ToString() { string result = String.Empty; if (Num1 != null) { result += Num1.ToString() + " "; if (Action != null) { result += Action + " "; } if (Num2 != null) { result += Num2.ToString(); } } else { result = "0"; } return(result); }
/// <summary> /// definition + operator for Nstring data type /// </summary> /// <param name="Num1"></param> /// <param name="Num2"></param> /// <returns></returns> public static NString operator +(NString Num1, NString Num2) { int maxLen; string maxnum; string minnum; StringBuilder build; if (Num1.Length > Num2.Length) { maxnum = Num1.ToString(); minnum = InitMinNum(Num2.ToString(), Num1.Length, Num2.Length); maxLen = maxnum.Length; build = new StringBuilder(maxLen + 1); } else if (Num2.Length > Num1.Length) { maxnum = Num2.ToString(); minnum = InitMinNum(Num2.ToString(), Num2.Length, Num1.Length); maxLen = maxnum.Length; build = new StringBuilder(maxLen + 1); } else { maxnum = "0" + Num1.ToString(); minnum = "0" + Num2.ToString(); maxLen = maxnum.Length; build = new StringBuilder(maxLen + 1); } int n1; int n2; int save = 0; int result; int sum; int i = maxLen - 1; for (; i >= 0; i--) { n1 = int.Parse(maxnum[i].ToString()); n2 = int.Parse(minnum[i].ToString()); sum = n1 + n2 + save; save = sum / 10; result = sum % 10; build.Append(result); } if (save != 0) { build.Append(save); } string res = Reverse(build.ToString()); return(new NString(res)); }
public List <string> GetAllValues() { return(new List <string> { Num1.ToString(), Num2.ToString(), Num3.ToString() }); }