Write an algorithm to input number of passengers travelling, Data Structure & Algorithms

Assignment Help:

There are ten stations on a railway line:

817_line.png

Train travels in both directions (i.e. from 1 to 10 and then from 10 to 1).  Fare between each station is $2.

A passenger inputs the number of station at the start of his journey and number of the destination station and fare is calculated (for example if a passenger gets on a station 3 and his destination is station 9 his fare would be $12). Calculation should take into account the direction of train (for example a passenger getting on at station 7 and getting off at station 1 will also pay $12 and not a negative value!!).

A discount of 10% is given if 3 or more passengers are travelling together.

Write an algorithm by using a flowchart that:

  • input number of passengers travelling
  • input station number of the starting point and the station number of the destination
  • calculates the total fare taking into account the direction of travel
  • calculates any discount due
  • outputs the cost of tickets and prints tickets

 

 


Related Discussions:- Write an algorithm to input number of passengers travelling

Avl tree rotations, AVL trees and the nodes it contains must meet strict ba...

AVL trees and the nodes it contains must meet strict balance requirements to maintain O(log n) search time. These balance restrictions are kept maintained via various rotation func

Binary search tree, A binary search tree (BST), which may sometimes also be...

A binary search tree (BST), which may sometimes also be named a sorted or ordered binary tree, is an edge based binary tree data structure which has the following functionalities:

Explain the assertions in ruby, Explain the Assertions in Ruby Ruby off...

Explain the Assertions in Ruby Ruby offers no support for assertions whatever. Moreover, because it's weakly typed, Ruby doesn't even enforce rudimentary type checking on opera

State in detail about the integer, State in detail about the Integer ...

State in detail about the Integer Carrier set of the Integer ADT is the set {..., -2, -1, 0, 1, 2, ...}, and  operations on these values are addition, multiplication, subtrac

What are the advantages of using assertions, Using Assertions When writ...

Using Assertions When writing code, programmer must state pre- and subtle post conditions for public operations, state class invariants and insert unreachable code assertions a

Define the term - array, Define the term - Array A fixed length, ord...

Define the term - Array A fixed length, ordered collection of values of same type stored in contiguous memory locations; collection may be ordered in several dimensions.

Applications in file systems of avl trees, 1. In computer science, a classi...

1. In computer science, a classic problem is how to dynamically store information so as to let for quick look up. This searching problem arises frequently in dictionaries, symbol t

Define the internal path length, Define the Internal Path Length The In...

Define the Internal Path Length The Internal Path Length I of an extended binary tree is explained as the sum of the lengths of the paths taken over all internal nodes- from th

Algorithm to insert element to a max-heap sequentially, Q. Write  down the ...

Q. Write  down the  algorithm  to  insert  an  element  to  a  max-heap  which  is  represented sequentially.           Ans: The algorithm to insert an element "newkey" to

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd