我正在尝试让TotalCost为其添加150,然后如果该区域更大,那么750再次为TotalCost添加50。
int TotalCost = 0;
double Area = Convert.ToDouble(SurfAreaTxt.Text);
if (WoodTxt.Text.ToLower() == mahogany)
{
TotalCost + 150;
if (Area > 750)
{
TotalCost += 50;
}
Console.Write(TotalCost);
}
答案 0 :(得分:2)
你几乎拥有它,只需将TotalCost + 150;
更改为TotalCost += 150;
。
你走了:
TotalCost = 0;
double Area = Convert.ToDouble(SurfAreaTxt.Text);
if (WoodTxt.Text.ToLower() == mahogany)
{
TotalCost += 150;
if (Area > 750)
TotalCost += 50;
Console.Write(TotalCost);
}