Using Switch Statements write a program that displays the fo

Using Switch Statements, write a program that displays the following menu for the seat ticket options available to the customer: • B= Balcony • F= Front • A= Random Seat • R= Rear The user inputs the type of seat and quantity. It finally displays the total charges for the order according to following criteria: • Balcony = $ 200 • Random Seat = $ 100 • Front = $ 500 • Rear = $ 150

Solution

Using Switch statement, we can divide the seats on basis of the character inputted by the user.

Following program illustrates it more clearly:

// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
int seat;
char choice;
cout<<\" Enter the type of seat you want:\ • B= Balcony \ • F= Front \ • A= Random Seat \ • R= Rear\ \";
cin>>choice;
cout<<\"enter the number of seat\ \";
cin>>seat;
switch(choice)
{
case \'B\' : cout<<\"\ Cost of seat (200$ per seat) is \" <<seat*200;break;
case \'F\' : cout<<\"\ Cost of seat (500$ per seat) is \" <<seat*500;break;
case \'A\' : cout<<\"\ Cost of seat (100$ per seat) is \" <<seat*100;break;
case \'R\' : cout<<\"\ Cost of seat (150$ per seat) is \" <<seat*150;break;
default: cout<<\"Invalid Option entered\";
}
return 0;
}

Using Switch Statements, write a program that displays the following menu for the seat ticket options available to the customer: • B= Balcony • F= Front • A= Ra

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site