0

ok i have this code working
-but i have few more questions guys,
-i wanted to put error trapping in the seatRes() function but have no idea how,
-i also wanted to make a function that will be able to cancel a reserve seat, and change it to another seat
-i also want to put error trapping when choosing a seat that has already been taken

i read some topics here in the site but i got lost and dont fully understand the pointers and references
they also gave me an idea about the boolean thing, but i cant understand how will i make it work

can anyone guide me please?

#include <iostream>
#include <conio.h>
using namespace std;

	int movieChoice;
	int seatNum;
	int seatPlan [5][10]={0};
	int rows,cols;
	char space;
	
void seatDisplay( int a[][10]);
void seatNew( int n[][10]);

void seatDisplay( int a[][10]){	//this function shows the seat plan
	
	for (int i=0;i<5;i++){
		for (int j=0;j<10;j++){
			cout<<a[i][j];
			cout<<" ";
		}
		cout<<endl;
	}
}

void seatNew( int n[][10]){ // this function shows the reserved seats
		
	for (int i=0;i<5;i++){
		for (int j=0;j<10;j++){
			cout<<n[i][j];
			cout<<" ";
		}
		cout<<endl;
	}
	
}


void seatRes(int x){  //this function reserves the seats
		
	while (x>50 || x<=0){
		cout<<"Cannot process Reservation."<<endl;
		cout<<"Please Enter number of seats to be reserved: ";
		cin>>x;
	}
	cout<<endl;
	cout<<"Please enter seat row and column you wish to reserve: \n";
	cout<<endl;
	for (int i=1;i<=x;i++){
		cout<<"(row,column): ";
		cin>>rows>>space>>cols;
		seatPlan[rows][cols]=1;
	}
}

int priceComp(int y){ //this function computes and displays the ticket price

	int price;
	price=y*150;
	cout<<endl;
	cout<<"You have reserved "<<y<<" seat(s).";
	cout<<endl;
	cout<<endl;
	cout<<"Ticket Price:       "<<price<<endl;
	cout<<endl;
	return 0;
}

int main(){ //this is the main function
	
	cout<<"Welcome to Movie World"<<endl;
	cout<<endl;
	cout<<"1 - Movie 1"<<endl;
	cout<<"2 - Movie 2"<<endl;
	cout<<"3 - Movie 3"<<endl;
	cout<<endl;
	cout<<endl;
	cout<<"Enter your choice of Movie: ";
	cin>>movieChoice;
	cout<<endl;
	
	switch (movieChoice){

		case 1: 
			cout<<endl;
			cout<<"Movie 1"<<endl;
			cout<<endl;
			cout<<"Seating Reservation"<<endl;
			cout<<endl;
			seatDisplay(seatPlan);
			cout<<"How many seats would you like to reserve?: ";
			cin>>seatNum;
			seatRes(seatNum);
			cout<<"Seating Reservation";
			cout<<endl;
			cout<<"1 marks your reserved seat \n";
			cout<<endl;
			cout<<"------Movie 1 SEAT PLAN----------- \n";
			cout<<endl;
			seatNew(seatPlan);
			priceComp(seatNum);			
			break;

		case 2: 
			cout<<endl;
			cout<<"Movie 2"<<endl;
			cout<<endl;
			cout<<"Seating Reservation"<<endl;
			cout<<endl;
			seatDisplay(seatPlan);
			cout<<"How many seats would you like to reserve?: ";
			cin>>seatNum;			
			seatRes(seatNum);
			cout<<"Seating Reservation";
			cout<<endl;
			cout<<"1 marks your reserved seat \n";
			cout<<"------Movie 2 SEAT PLAN----------- \n";
			cout<<endl;
			seatNew(seatPlan);
			priceComp(seatNum);
			break;

		case 3: 
			cout<<endl;
			cout<<"Movie 3"<<endl;
			cout<<endl;
			cout<<"Seating Reservation"<<endl;
			cout<<endl;
			seatDisplay(seatPlan);
			cout<<"How many seats would you like to reserve?: ";
			cin>>seatNum;
			seatRes(seatNum);
			cout<<"Seating Reservation";
			cout<<endl;
			cout<<"1 marks your reserved seat \n";
			cout<<"------Movie 3 SEAT PLAN----------- \n";
			cout<<endl;
			seatNew(seatPlan);
			priceComp(seatNum);
			break;

		default:
			cout<<endl;
			cout<<"Invalid Input"<<endl;
	
	}
	return 0;
			_getch();
}

Edited by Ezzaral: Fixed code tag.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by daviddoria
0

I suggest trying to boil down your problems into very small demos. In many cases it will help you identify what is going wrong enough that you can solve it yourself. If not, it will produce a helpful question/answer pair for DaniWeb. Once you figure it out, if you don't already see something similar here: http://programmingexamples.net/index.php?title=CPP I would encourage you to add an example.

David

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.