|
-
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
-
Apr 15th, 2005, 03:27 AM
#2
Hyperactive Member
Re: Taxi fares
Out of interest could you post your response?
-
Apr 15th, 2005, 01:32 PM
#3
-
Apr 15th, 2005, 05:58 PM
#4
Re: Taxi fares
How would you know how much time the cab spends doing under 6 mph?
-
Apr 15th, 2005, 06:02 PM
#5
Re: Taxi fares
I probably would of just given him a thorough flowchart (to show off my impecible organizational skills) and explained that although there are many ways to code the project, it alway has to start with the flowchart. BAM! got the job
kevin
Last edited by kebo; Apr 15th, 2005 at 08:23 PM.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Apr 15th, 2005, 08:36 PM
#6
Re: Taxi fares
 Originally Posted by kulrom
this is very real situation and it could be resolved ... but i'm not sure that it goes so easy ... actually, one hour should not be enough time to accomplish all those tasks even if you are skilled developer you can't draw up solution fairly quickly .... anyway you didn't get the job ... sorry  more lucky next time 
This task doesn't seem too complicated and any decent developer should be able to lay down some mock-logic in 10-15min.
The problem I find with the question is
- 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.
We are not give any information on this and thus, unless me make some creative assumtions, it is not solvable.
Also, if it were to hit peak hours during a ride, would should the surcharge(s) apply?
Also, shouldn't we be provided with a time when the ride ended?
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Apr 15th, 2005, 10:00 PM
#7
-
Apr 16th, 2005, 10:08 AM
#8
Thread Starter
New Member
Re: Taxi fares
It was online prescreen test. I may include any supplemental items or information I desire.
I did the following way:
Fare newFare = new Fare();
newFare.Calculate (rideStart, blocksTraveled) ;
I just wondering how to implement Calculate function? As an abstract, interface or overriding? How would you do it?
-
Apr 16th, 2005, 10:13 AM
#9
Re: Taxi fares
NYC is a unique place. 10 blocks is a mile - so 1/5th a mile is two blocks.
Traffic either crawls at less than 6 miles per hour (on the streets) or goes 50 miles an hour up the avenues!
The lights are timed so that you get through dozens of them at a shot - then stop - then go again.
This function would need to be called whenever speed changed from +6 to <6 miles per hour - so that the portion of travel just digested is charged - that's the way the meters work in real life.
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
|