Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BEGIN Fare_Calculator
- Set fare = 0
- Set x = 0, y = 0
- Set distance = 0
- Set south_var = 0, north_var = 0, east_var = 0, west_var = 0
- DOWHILE direction != -1
- Prompt for direction
- get direction
- If (direction_input ==”NORTH”) THEN
- Set y = y+1
- ENDIF
- If (direction_input ==”SOUTH”) THEN
- Set y=y-1
- ENDIF
- If (direction_input ==”EAST”) THEN
- set x = x+1
- ENDIF
- If (direction_input ==”WEST”) THEN
- Set x=x-1
- ENDIF
- If direction == -1
- Print error message
- Prompt and get direction
- ENDIF
- DOWHILE x <>0 and y <>0 and direction <>-1
- Prompt for distance, get distance
- distance = distance + distance
- ENDDO
- ENDDO
- Set north = y+1, south = y-1, east = x + 1, west = x-1
- Set fare = 5+ (8*north) + (8*south) + (8*west) + (8*east)
- Print total distance, fare, final coordinates
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement