|
-
Apr 14th, 2005, 09:28 PM
#1
Thread Starter
New Member
Taxi fares
I had the following question on job interview. It took 1 hour for me to write the code for this program, but interviewer said that my design was not good. How would you do design for this problem? Any tips will be appreciated.
Background
====
Taxi fares in New York City are regulated by the Taxi & Limousine Commission (TLC) and calculated by meter. The rate of fare is as follows:
- The sum of $2.50 is payable upon entry.
- $0.40 is paid for every additional unit.
- A unit fare is one-fifth of a mile when the taxicab is traveling 6 mph or more; or
- 120 seconds (at a rate of 20 cents per minute), when the taxicab is not in motion or is traveling at less than 6 mph.
There is an additional night surcharge of $0.50 after 8:00 pm and before 6:00 am. There is also a peak weekday surcharge of $1.00 after 4:00 pm and before 8:00 pm.
There are 20 New York City blocks to the mile.
Problem Definition
====
You will be provided with an array of integers representing the number of blocks the cab travels a passenger’s ride. You will also be provided with a DateTime value indicating the exact moment in time when the taxi ride is considered to have begun.
You are to calculate the total fares in dollars and cents.
Return the total fare as a normally formatted USD string.
You are to expose your calculation functionality as a public instance method named Calculate. The method’s ordered parameters should be as follows:
DateTime rideStart, int[] blocksTraveled
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|