โปรแกรมจองตั๋วหนัง

แนะนำ สอบถาม ภาษา C สำหรับผู้เริ่มต้น

Moderator:

User avatar
nokroo
Posts: 188
Joined: 01/01/1970 7:00 am
Location: วัดตะคร้ำเอน ต.ตะคร้ำเอน อ.ท่ามะกา จ.กาญจนบุรี

โปรแกรมจองตั๋วหนัง

Postby nokroo » 05/10/2013 8:21 am

#include <iostream.h>
#include <conio.h>

using namespace std;

int main ()
{
int movie1;
int movie2;
int movie3;
int seats;
int price;
int select;
char response;

cout <<"\n\n______Wellcome to Strawberry Gold Cinema____\n\n"<<"Now you are booking a ticket cinema and please choose your movie... ";
cout <<"\n\nPress 1 for= Harry Potter \n\n"<<"\n\nPress 2 for = Iron Man\n\n"<<"\n\nPress 3 for = Romeo and Juliet;\n\n";
cin >> select;


if (select ==1 )

{


cout<<"\n\nThe price of the ticket per seat is RM10.00 \n\n"<<"\n\nPlease enter the number of seat \n\n";
cin>>seats;


if (seats<=30)

{
price = 10 * seats;

cout<<"The total price is RM "<<price<<endl;
}

else if (seats>=30)

{
cout<<"\n\nThe movie is full. \n\n"<<"\n\nWould like to choose another movie?? "<<"\n\nSection Y or N \n\n";
cout<<"\n\nEnter your choice = \n\n";
cin>>response;
}



if ( toupper( response ) == 'Y' )
{
cout <<"\n\nPlease choose movie 2 or movie 3 \n\n"<<"\n\nEnter your choice \n\n";
cin>>select;




if (select == 2)
{
cout<<"\n\nThe price of the ticket per seat is RM11.00 \n\n"<<"\n\nPlease enter the number of seat \n\n";
cin>>seats;


if (seats<=30)

{
price = 11 * seats;

cout<<"The total price is RM "<<price<<endl;
}

}
else if (seats>=30)

{
cout<<"\n\nThe movie is full. \n\n"<<"\n\nWould like to choose another movie?? \n\n"<<"\n\nSection Y or N \n\n";
cout<<"\n\nEnter your choice = \n\n";
cin>>response;

}
if ( toupper( response ) == 'Y' )


{
cout<<"\n\nThe price of the ticket per seat is RM13.00"<<"Please enter the number of seat \n\n";
cin>>seats;


if (seats<=30)

{
price = 13 * seats;

cout<<"The total price is RM"<<price<<endl;
}

else if (seats>=30)

{
cout<<"The movie is full."<<"Next movie in 5 hours...."<<endl;
}

else
cout << "\n\nNext movie in 5 hours. \n\n";
}
}
}

//for 2

if (select ==2 )

{


cout<<"\n\nThe price of the ticket per seat is RM11.00 \n\n"<<"\n\nPlease enter the number of seat \n\n";
cin>>seats;


if (seats<=30)

{
price = 11 * seats;

cout<<"The total price is RM"<<price<<endl;
}

else if (seats>=30)

{
cout<<"\n\nThe movie is full. \n\n"<<"\n\nWould like to choose another movie?? \n\n"<<"\n\nSection Y or N \n\n";
cout<<"\n\nEnter your choice = \n\n";
cin>>response;
}



if ( toupper( response ) == 'Y' )
{
cout <<"\n\nPlease choose movie 1 or movie 3 \n\n"<<"\n\nEnter your choice \n\n";
cin>>select;




if (select == 2)
{
cout<<"\n\nThe price of the ticket per seat is RM10.00 \n\n"<<"\n\nPlease enter the number of seat \n\n";
cin>>seats;


if (seats<=30)

{
price = 10 * seats;

cout<<"The total price is RM"<<price<<endl;
}

}
else if (seats>=30)

{
cout<<"\n\nThe movie is full.\n\n"<<"\n\nWould like to choose another movie?? \n\n"<<"\n\nSection Y or N \n\n";
cout<<"\n\nEnter your choice = \n\n";
cin>>response;

}
if ( toupper( response ) == 'Y' )


{
cout<<"\n\nThe price of the ticket per seat is RM13.00 \n\n"<<"\n\nPlease enter the number of seat \n\n";
cin>>seats;


if (seats<=30)

{
price = 13 * seats;

cout<<"The total price is RM"<<price<<endl;
}

else if (seats>=30)

{
cout<<"The movie is full."<<"Next movie in 5 hours...."<<endl;
}
else
cout << "\n\nNext movie in 5 hours. \n\n";

}
}
}



//for seat 3

if (select ==3 )

{


cout<<"\n\nThe price of the ticket per seat is RM13.00 \n\n"<<"\n\nPlease enter the number of seat\n\n";
cin>>seats;


if (seats<=30)

{
price = 13 * seats;

cout<<"The total price is RM"<<price<<endl;
}

else if (seats>=30)

{
cout<<\n\n"The movie is full. \n\n"<<"\n\nWould like to choose another movie?? \n\n"<<"\n\nSection Y or N \n\n";
cout<<"\n\nEnter your choice = \n\n";
cin>>response;
}



if ( toupper( response ) == 'Y' )
{
cout <<"\n\nPlease choose movie 1 or movie 2\n\n"<<"\n\nEnter your choice \n\n";
cin>>select;




if (select == 1)
{
cout<<"\n\nThe price of the ticket per seat is RM10.00 \n\n"<<"\n\nPlease enter the number of seat \n\n";
cin>>seats;


if (seats<=30)

{
price = 10 * seats;

cout<<"The total price is RM"<<price<<endl;
}

}
else if (seats>=30)

{
cout<<"\n\nThe movie is full. \n\n"<<"\n\nWould like to choose another movie?? \n\n"<<"\n\nSection Y or N \n\n";
cout<<"\n\nEnter your choice = \n\n";
cin>>response;

}
if ( toupper( response ) == 'Y' )


{
cout<<"\n\nThe price of the ticket per seat is RM12.00 \n\n"<<"\n\nPlease enter the number of seat \n\n";
cin>>seats;


if (seats<=30)

{
price = 12 * seats;

cout<<"The total price is RM"<<price<<endl;
}

else if (seats>=30)

{
cout<<"The movie is full."<<"Next movie in 5 hours...."<<endl;
}
else
cout << "\n\nNext movie in 5 hours.\n\n";
}
}
}
getch();
}

/*http://stackoverflow.com/questions/3895908/if-else-program-to-switch-program*/

Return to “Programming - C/C<sup>++</sup>& java”

Who is online

Users browsing this forum: No registered users and 2 guests