我的学校项目需要帮助.我一直在努力,最终想出如何输出开始里程表和结束里程表=总里程驱动.对于总费用,我需要每天增加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;
Run Code Online (Sandbox Code Playgroud)
如你所见,我使用finalCostDecimal等于totalmilesdecimal*$ 0.12 + rentedDecimal + 15.我不认为我使用了正确的代码.有人可以帮我吗?我被困住并尝试了很多.谢谢!
如果rentedDecimal是租车的天数,那么您的计算应该是:
finalCostDecimal = (totalMilesDecimal * 0.12m) + (rentedDecimal * 15.0m);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1725 次 |
| 最近记录: |