-2
我需要幫助我的車程序。我想使它所以當你點擊一個汽車收音機按鈕,可以說,我想布加迪,我會點擊布加迪單選按鈕,它會計算這個代碼的最終成本:我的汽車租賃計劃2 C#?
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();
}
}
是我的代碼嗎?當我點擊其中一個單選按鈕時,他們都計算相同的成本。
我建議在設置'lblFinalCost.Text'的兩個地方設置斷點。確保它們被調用並檢查'____ Decimal'變量中的值以確保它們符合您的預期。如果你不知道的話,可以通過按'F9'在Visual Studio的一行中設置一個斷點。 –
照片改變了嗎? –
它似乎總是在計算蘭博基尼? – JLott