我的汽车计划需要帮助。我正在努力做到这一点,所以当你点击汽车单选按钮时,假设我想要一辆布加迪,我会点击布加迪单选按钮,它会通过以下代码计算最终成本:
bugattiDecimal = bugattiFinal * (Decimal)0.20 + rentedDecimal * 25;
该代码应该计算每英里 0.20 美元和每天 25 美元的租金。
这是代码的其余部分:
//Step 3: Mathmatematical Calculations.
totalMilesDecimal = endingOdometerDecimal - beginningOdometerDecimal;
lamborghiniFinal = endingOdometerDecimal - beginningOdometerDecimal;
ferrariFinal = endingOdometerDecimal - beginningOdometerDecimal;
bugattiFinal = endingOdometerDecimal - beginningOdometerDecimal;
lamborghiniDecimal = lamborghiniFinal * (Decimal)0.12 + rentedDecimal * 15;
ferrariDecimal = ferrariFinal * (Decimal)0.15 + rentedDecimal * 20;
bugattiDecimal = bugattiFinal * (Decimal)0.20 + rentedDecimal * 25;
//This shows the picture.
if (radLamborghini.Checked) {
picLamborghini.Visible = true;
picFerrari.Visible = false;
picBugatti.Visible = false;
}
if (radLamborghini.Checked) {
lblFinalCost.Text = lamborghiniDecimal.ToString();
}
private void radFerrari_CheckedChanged(object sender, EventArgs e)
{
//This shows the picture.
if (radFerrari.Checked) {
picFerrari.Visible = true;
picLamborghini.Visible = false;
picBugatti.Visible = false;
}
if (radFerrari.Checked) {
lblFinalCost.Text = ferrariDecimal.ToString();
}
}
private void radBugatti_CheckedChanged(object sender, EventArgs e)
{
//This shows the picture.
if (radBugatti.Checked) {
picBugatti.Visible = true;
picLamborghini.Visible = false;
picFerrari.Visible = false;
}
if (radBugatti.Checked) {
lblFinalCost.Text = bugattiDecimal.ToString();
}
}
我的代码对吗?当我单击其中一个单选按钮时,它们都会计算相同的成本。