Home » , » C++ if-else and switch statement Example

C++ if-else and switch statement Example


Problem Statement: Online Railway Reservation System Lahore....

You are required to write a program for Online Railway Reservation System Lahore. The basic idea is that user will provide passenger information, Reservation Class, city name and number of Tickets. Upon this information your program will calculate the fare amount for that Reservation.


Detailed Description:

1.      The program should display

Please provide Passenger Name:

Please provide Reservation Class Description.

       

Press “1” for Air-Conditioned Sleeper

Press “2” for Air-Conditioned Business

Press “3” for Economy

2.      Depending upon the choices that user has entered; your program will further display the prompt:

3.      If user has entered Reservation Class description, then your program should prompt the user to enter the City Name and Number of Tickets:
-----------------------------------------------------------------
Please provide City Description.  

Press “S” for Sahiwal

Press “K” for Karachi

Press “M” for Multan

[If user press ‘K’]
-----------------------------------------------------------------
  Welcome to Lahore – Karachi Railway System:

  Number of Tickets:
-----------------------------------------------------------------

4.      After getting all this information, now write a function which will calculate Fare amount on the basis of this information:

   To calculate Fare amount we will use this formula:
   Fare amount =  charged amount * number of Tickets

5.     Charged amount will be different for different Cities according to following description:

For Lahore - Sahiwal
Air-Conditioned Sleeper      : 950 PKR
Air-Conditioned Business    : 800 PKR
Economy                                 : 425 PKR

For Lahore - Karachi
Air-Conditioned Sleeper     : 1380 PKR
Air-Conditioned Business   : 1250 PKR
Economy                                : 830 PKR

For Lahore - Multan
Air-Conditioned Sleeper     : 980 PKR
Air-Conditioned Business   : 830 PKR
Economy                                : 450 PKR

6.      After calculating charged amount for city and display it on the screen:


Solved Code:

LIKE US

Popular Posts

My FANS around the WORLD

Flag Counter