我在学校的项目上需要帮助。我一直在研究它,并最终想出了如何输出起始里程计和终点里程计=总里程驱动。总费用,我需要它增加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等于总计十进制* $0.12 + rentedDecimal + 15,我认为我没有使用正确的代码。有人能帮帮我吗?我被困住了,已经试了很多次了。谢谢!
发布于 2013-10-07 23:51:02
如果rentedDecimal是租用汽车的天数,那么您的计算应该是:
finalCostDecimal = (totalMilesDecimal * 0.12m) + (rentedDecimal * 15.0m);发布于 2013-10-07 23:52:13
每天租用15美元,另加每英里0.12美元
(每天租用15美元)加(每英里0.12美元)
(租用15美元*天)+(0.12美元*英里)
finalCostDecimal = (15 * rentedDecimal) + (0.12 * totalMilesDecimal)https://stackoverflow.com/questions/19236733
复制相似问题