Return to Website

Forum ShymzOnline

Selamat Datang Ke Forum ShymzOnline!

Forum ShymzOnline
Start a New Topic 
Author
Comment
C++

//Contoh program untuk bas.....ta tau jalan ke tak!


#include
#include

int main()
{
clrscr();
char passenger;
int seat , curseat, destination, i;

do
{
printf("Reserve tickets? (Y/N): ");
scanf("%s", &passenger);

/*Check whether to assign passenger or not*/
if (passenger == 'y' ~~ passenger == 'Y')

{
printf("n<>");
printf("n<>n");
scanf ("%d", &destination);


/*Which destination have been assign*/
switch(destination)
{
case 1: /*Sarikei*/
curseat = 0;

/*Look for all the seat*/
for(i=0; i<5; i++)
{
/*If seat are full*/
if(seat == 1)
{
/*Assign seat for the next seat */
curseat = curseat + 1;
}
}
if (curseat < 5) /*If available*/
{
printf("n*****BIARAMAS EXPRESS*****");
printf("n***Destination for Sarikei at 8:00 a.m***");
printf("nSeat No.:%d still avaiablen", curseat +1);
printf("n**********************************nn");
}
/*Check whether the seat is still available or not
*/
if (curseat < 5) /*If available*/
{
printf("Booked ticket? (Y/N): ");
scanf("%s", &passenger);

/*Check whether to assign passenger or not*/
if (passenger == 'y');

/*Mark the first class is full*/
seat[curseat] = 1;

break;

}
else /*If Full*/
{
printf("nSorry, the bus at 8:00 a.m are full!");
printf("nPlease choose the next avaiable busnn");
printf("Booked ticket on the next avaiable bus? (Y/N): ");
scanf("%s", &passenger);