User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 397,600 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,674 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting

Airline Reservation System..

Join Date: Apr 2007
Posts: 3
Reputation: imastudent is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
imastudent imastudent is offline Offline
Newbie Poster

Re: Airline Reservation System..

  #3  
Apr 23rd, 2007
Hi again..this is what i do so far..
but there is still a problem, bcos my teacher told me that the seats must be randomly assigned..So for example, user choose Business, then the seats go random between 1 to 5..

<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Solution11.16 -->
<!-- Airline Reservation System-->

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
<title>Airline Reservation System</title>

<script type = "text/javascript">
<!--

var input;
var secondInput;
var element;
var secondElement;
var firstCount = 0;
var economyCount = 0;
var seats = [ ,0,0,0,0,0,0,0,0,0,0]; //allocate 10-element Array

function startArray()
{


for(var i=0; i<11; i++)
{

input = window.prompt("Please type 1 for First Class and Please type 2 for Economy.","0");

if (input == 1 || input == 2)
{
element = linearSearch(seats);
if (element==-1 && input == 1)
{
document.writeln("The First Class is already fully booked<br/>");
secondQuestion(seats);
}
else if (element ==-1 && input == 2)
{
document.writeln("The Economy Class is already fully booked<br/>");
secondQuestion(seats);
}
else
boardingPass(input);
}


//to terminate the program
else
{
window.status = "Bye-bye!";
System.exit(0);
}


}
}

function linearSearch(theArray)
{
if (input == 1)
{
for (var n=0; n<6 ; n++)
if (theArray [n] == 0)
return n;
}
else if (input == 2)
{
for (var n=6; n<11 ; n++)
if (theArray [n] == 0)
return n;
}
return -1;
}

function boardingPass(theInput)
{
if (input ==1)
{
document.writeln("----------BOARDING PASS----------<br/>");
document.writeln("You are allocated in the First Class<br/>");
document.writeln("Your seat number is "+ element+"<br/>");
document.writeln("-----------------------------------------<br/>");
seats[element]= 1;
firstCount++;
}
else if (input ==2)
{
document.writeln("----------BOARDING PASS----------<br/>");
document.writeln("You are allocated in the Economy Class<br/>");
document.writeln("Your seat number is "+ element +"<br/>");
document.writeln("-----------------------------------------<br/>");
seats[element]= 1;
economyCount++;
}

}

function secondQuestion(theArray)
{
if (input == 1)
{
for (var n=6; n<11 ;n++)
{
if (theArray [n] == 0)
{
secondInput = window.prompt("Do you want to move to Economy Class? (If YES, please press 1. If NO, please press 2)","0");
if ( secondInput == 1)
{

input = 2;
element=linearSearch(seats);
document.writeln("You have been allocated to Economy Class<br/>");
boardingPass(input);
break;
}
else if (secondInput == 2)
{
document.writeln("Next flight leaves in 3 hours<br/>");
break;
}
}
}
}
else if (input == 2)
{
for (var n=0; n<6 ;n++)
{
if (theArray [n] == 0)
{
secondInput = window.prompt("Do you want to move to First Class? (If YES, please press 1. If NO, please press 2)","0");
if ( secondInput == 1)
{
input = 1;
element=linearSearch(seats);
document.writeln("You have been allocated to First Class<br/>");
boardingPass(input);
break;
}
else if (secondInput == 2)
{
document.writeln("Next flight leaves in 3 hours<br/>");
break;
}
}
}
}

}


//-->
</script>

</head>
<body onload = "startArray()"></body>
</html>
Reply With Quote  
All times are GMT -4. The time now is 6:58 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC