Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. BEGIN Fare_Calculator
  2. Set fare = 0
  3. Set x = 0, y = 0
  4. Set distance = 0
  5. Set south_var = 0, north_var = 0, east_var = 0, west_var = 0
  6. DOWHILE direction != -1
  7. Prompt for direction
  8. get direction
  9. If (direction_input ==”NORTH”) THEN
  10. Set y = y+1
  11. ENDIF
  12. If (direction_input ==”SOUTH”) THEN
  13. Set y=y-1
  14. ENDIF
  15. If (direction_input ==”EAST”) THEN
  16. set x = x+1
  17. ENDIF
  18. If (direction_input ==”WEST”) THEN
  19. Set x=x-1
  20. ENDIF
  21. If direction == -1
  22. Print error message
  23. Prompt and get direction
  24. ENDIF
  25. DOWHILE x <>0 and y <>0 and direction <>-1
  26. Prompt for distance, get distance
  27. distance = distance + distance
  28. ENDDO
  29. ENDDO
  30. Set north = y+1, south = y-1, east = x + 1, west = x-1
  31. Set fare = 5+ (8*north) + (8*south) + (8*west) + (8*east)
  32. Print total distance, fare, final coordinates
  33. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement