我需要帮助与我的学校项目。我一直在研究它,并最终想出如何输出开始的里程表和结束里程表=总里程驱动。对于总成本,我需要每天增加15美元租金,再加上每英里0.12美元。我将如何做到这一点?下面是代码我现在有:汽车租赁计划C#
//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.我不认为我用正确的代码。任何人都可以在这里帮我吗?我卡住了,并尝试了很多。谢谢!
这是基本的三年级算术:( –
@Gunnar Bates当你开始编程时,编写代码之前可能更容易写下你要做的事情。 (例如写下所有需要的计算)我假设你应该知道如何进行计算,但是你被代码弄糊涂了。 –
@JoelCoehoorn:至少他有一些代码可以和.. – NotMe