Results 1 to 9 of 9

Thread: Taxi fares

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    4

    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

  2. #2
    Hyperactive Member
    Join Date
    Feb 2003
    Posts
    263

    Re: Taxi fares

    Out of interest could you post your response?

  3. #3
    Member Retali8's Avatar
    Join Date
    Mar 2005
    Location
    Toronto
    Posts
    49

    Thumbs down Re: Taxi fares

    that was a job interview question...sounds more like a school test question.

  4. #4
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Taxi fares

    How would you know how much time the cab spends doing under 6 mph?

  5. #5
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    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

  6. #6
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Re: Taxi fares

    Quote 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

  7. #7
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Taxi fares

    What I would do is make a 3D taxi-like environment using DirectX9 with it calculating in real time. Only I would add a twist to it. Crazy Taxi anyone?

    BAM!

    I got the job.

    Anyway's, this doesn't sound like a job interview question at all. More like a school question. Job interviews involve your qualifications, your experience, your previous jobs, your educational background.... through your resume

    Then your employer will just ask you questions. Once you are hired, they will usually put you through training, and show you the ropes.

    Interviews can't be expressed using simple school projects like this. That's just not how the real world works.

  8. #8

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    4

    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?

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width