我需要幫助與我的學校項目。我一直在研究它,並最終想出如何輸出開始的里程錶和結束里程錶=總里程驅動。對於總成本,我需要每天增加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