我正在尝试以 C# 形式制作分数计算器。
我只是无法正确计算这是 我的表格
我希望它能够计算结果。当您输入 10/5 和 10/7 时,结果应该是 3 3/7 或者像这样 结果应该如何
我得到什么 我的结果
这是我的代码
private void button1_Click(object sender, EventArgs e) // result bottom
{
double box_In_Top_Left = Convert.ToDouble(textBox1.Text); // Right UPPER BOX
double box_In_Down_Left = Convert.ToDouble(textBox2.Text); // Venstra Nederst string
double box_In_Top_Right = Convert.ToDouble(textBox3.Text); // Højre OP string
double box_In_Down_Right = Convert.ToDouble(textBox4.Text); // Højre Nederst String
double whole = box_In_Down_Right * box_In_Down_Left; // Whole (Bottom Part of A fraction
string whole_String = Convert.ToString(whole); // Converts the Whole to a string
textBox7.Text = whole_String; // Shows the Answer in the box in the bottom right
double Calculation1 = box_In_Top_Left * box_In_Down_Right; // Calculates the top lefts box result
double Calculation2 = box_In_Top_Right * box_In_Down_Left; // Calculates the top right box Result
double part = Calculation2 + Calculation1; // Calculates answer for the top box
string part_String = Convert.ToString(part);
if (part >= whole) // if the part is bigger then the whole
{
double Amount_Of_times_greater = part / whole;
string string_Amount_Of_times_greater = Convert.ToString(Amount_Of_times_greater);
double Ekstra_greatnes = part / Amount_Of_times_greater;
textBox6.Text = string_Amount_Of_times_greater;
double Part_Whole = (part / Amount_Of_times_greater);
if (Ekstra_greatnes == whole)
{
Part_Whole = Part_Whole - whole;
string string_Part_Whole = Convert.ToString(Part_Whole);
textBox8.Text = string_Part_Whole;
}
}
眼眸繁星
富国沪深
相关分类