Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Arrow Check difference between no. of stops, calculate cost

    Hi everyone,

    I’m working on a public transport card system which records the no. of stops of the journey and then calculates the costs. I’m a bit lost with this program and I hope you can help me...

    Features; the fare for up to 3 stops is charged £4, after than each stop is calculated as £2. How can I calculate the difference in stops between firstStop and lastStop? Also, how do I calculate the price? Let’s say they get on the bus on ‘stop 3’ and go to ‘stop 9’, how would I code this?

    From what I know, it seems that I have to do two different things;

    a) Firstly, code a calculation which checks the difference between the stops, i.e. 6 stops – but then again, what if they go from ‘stop 7’ to ‘stop 2’? I will end up with negative numbers!

    b) Secondly, I have to put the no. of stops in a calculation that will determine the cost...

    So in short I need help with the following;

    1)
    How can I calculate the difference between the stops without going into negative figure?
    2) How can I code a calculation which says; if stops = ‘1, 2, 3’ then charge £4, anything higher add £2 for each stop.

    I urgently need some guidance regarding this,
    Thanks.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Basically you have number of locations to stop, say 1,2,3...... and so on. You've seen this order when you traveling from one direction. What happen if you travel to other direction? Then the order is .....3,2,1. In that sense you have to keep track on which direction you are traveling. How you going to solve that?

    Can you show your effort here.

Similar Threads

  1. sound works then stops!
    By smileii in forum CLDC and MIDP
    Replies: 0
    Last Post: 09-26-2009, 12:06 AM
  2. Stops when opening ObjectInputStream
    By Norberhuis in forum Networking
    Replies: 4
    Last Post: 01-09-2009, 04:19 PM
  3. Replies: 0
    Last Post: 04-12-2008, 08:38 PM
  4. Bouncing Ball Just Suddenly Stops Mid Bounce
    By adlb1300 in forum Java 2D
    Replies: 1
    Last Post: 12-03-2007, 02:58 PM

Posting Permissions

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