Define a Class with Constructor in C++. (TOURIST)


Define a class TOURIST in C++ with the following specification:

Data members
  • ·         CarNo to store Car Number
  • ·         Origin to store Place name
  • ·         Destination to store Place name
  • ·         Type to store Car Type such as ‘E’ for Economy
  • ·         Distance to store the Distance in Kilometers
  • ·         Charge to store the Car Fare
  •  

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


Type
Fare
‘E’
16*Distance
‘A’
22*Distance
‘L’
30*Distance

  • ·         A function Enter() to allow user to enter values for CarNo, Origin, Destination, 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.