Click here to Skip to main content
15,868,292 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm doing project car parking system in that i want to calculate total amount means if the user parks car for 10 minutes i want to make charge of 10Rs. Please can anyone how to calculate in c# Thank...... In Advance
Posted
Comments
StM0n 16-Feb-15 1:24am    
So... 1 Minute is 1 Rupee?

First Of all you need to find out difference between in-time and out-time in minutes. then divide calculated time with 10 and multiply with 10.
 
Share this answer
 
v4
Comments
George Jonsson 16-Feb-15 1:49am    
So many errors in so little code.
1. return type should be double, not void
2. Variables and data types are reversed.
public double CalculateAmount(DateTime InTime, DateTime OutTime)
3. DateDiff is a VB function, right?
Richard MacCutchan 16-Feb-15 4:26am    
DoubleAmount = (timespan /10)*10; ???
The variable Rate is never used.
You are trying to return a variable that does not exist.
Here is a c# version of solution 1.
C#
public double ActualParkingFee(DateTime checkIn, DateTime checkOut)
{
    TimeSpan timeDiff = checkOut - checkIn;
    double fee = timeDiff.TotalMinutes;   // 1 RS / min, so no need for extra calculations
    return fee;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900