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

Write an algorithm for binary search., Write an algorithm for binary search...

Write an algorithm for binary search. Algorithm for Binary Search 1.  if (low> high) 2.  return (-1) 3.  Mid = (low + high)/2 4.  if ( X = = a[mid]) 5.  return (mid); 6.

Algorithm, Describe different methods of developing algorithms with example...

Describe different methods of developing algorithms with examples.

What are the example of area subdivision method, Example of Area Subdivisio...

Example of Area Subdivision Method The procedure will be explained with respect to an illustrative problem, with the image consisting of five objects, namely a triangle (T), qu

frequenty count of function, Ask question find frequency count of function...

Ask question find frequency count of function- {for(i=1;i {for(j=1;j {for(k=1;k } } }

Signals, How does cpu''s part tming and controls generate and controls sign...

How does cpu''s part tming and controls generate and controls signls in computer?

Prims algorithm, how to implement prims algorithm dynamically

how to implement prims algorithm dynamically

Explain how two dimensional arrays are represented in memory, Explain how t...

Explain how two dimensional arrays are represented in memory. Representation of two-dimensional arrays in memory:- Let grades be a 2-D array as grades [3][4]. The array will

Areas of use - sequential files, Sequential files are most frequently utili...

Sequential files are most frequently utilized in commercial batch oriented data processing where there is the concept of a master file on which details are inserted periodically. F

Diophantine Equations, Implement algorithm to solve 5-1 fifth order equati...

Implement algorithm to solve 5-1 fifth order equation given.

Er diagram, Ask queConsider the following functional dependencies: Applican...

Ask queConsider the following functional dependencies: Applicant_ID -> Applicant_Name Applicant_ID -> Applicant_Address Position_ID -> Positoin_Title Position_ID -> Date_Position_O

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