我的学校项目需要帮助。我一直在研究它,终于想出了如何输出开始里程表和结束里程表 = 总行驶里程。对于总成本,我需要它增加每天租用的 15 美元,再加上每英里 0.12 美元。我该怎么做?这是我现在拥有的代码:
//Step 1: Declaring variables to store our information.
decimal beginningOdometerDecimal;
decimal endingOdometerDecimal;
decimal rentedDecimal;
decimal totalSaleDecimal;
decimal averageSalesDecimal;
decimal carsReturned;
decimal totalMilesDecimal;
decimal finalCostDecimal;
//Step 2: Get the information from the user.
beginningOdometerDecimal = Decimal.Parse(txtBegin.Text);
endingOdometerDecimal = Decimal.Parse(txtEnd.Text);
rentedDecimal = Decimal.Parse(txtRent.Text);
//Step 3: Mathmatematical Calculations.
totalMilesDecimal = endingOdometerDecimal - beginningOdometerDecimal;
finalCostDecimal = totalMilesDecimal * (Decimal)0.12 + rentedDecimal + 15;
如您所见,我使用的 finalCostDecimal 等于 totalmilesdecimal * $0.12 + rentedDecimal + 15。我认为我使用的代码不正确。任何人都可以在这里帮助我吗?我被卡住了,已经尝试了很多。谢谢!