Define a class with constructor in C++. (BUS)


Define a class BUS in C++ with the following specifications:

Data members
  • ·         BusNo to store Bus Number
  • ·         From to store Place name of region
  • ·         To to store Place name of destination
  • ·         Type to store Bus Type such as ‘O’ for ordinary
  • ·         Distance to store the Bus Fare
  • ·         Fare to store the Bus Fare

Member functions
  • ·         A constructor function to initialise Type as ‘O’ and Freight as 500
  • ·         A function CalcFare() to calculate Fare as per the following criteria:


Type
Fare
‘O’
15*Distance
‘E’
20*Distance
‘L’
24*Distance

  • ·         A function Allocate() to allow user to enter values for BusNo, From, To, Type and Distance. Also, this function should call CalcFare() to calculate Fare.
  • ·         A function Show() to display the content of all the data members on screen.




No comments

Post your comments

Powered by Blogger.