Question

Please modify the follow source code to also include the following: 1. Add two more flights...

Please modify the follow source code to also include the following:

1. Add two more flights from these two airlines: United and AA, and makeup all the related information. Make sure the user can pick those flight numbers (United & AA) form the prompt box.

2. Add an array to hold "Departure Time" for all the flights. (Time format: "0800A", "1135P" ...)

3. If the user type in a flight number is not in the flight record, send out a flight number not found message using alert(), don't print out any flight information and stop the program.

Code to be modified (copy and pasted from notepad++):

<html>
<head>
<title>Flying from Boston</title>
<script language="javascript">

<!-- hide script away from browsers
function flightInfo(got) {
   //obtain flight info
   for (i=0; i<6; i++) {
       if (got == flightNumber[i]) break;
   }//for
       //print results
       document.write("Here is your flight info:<br />");
       document.write("Airline: " + airline[i] + "<br />");
       document.write("Flight Number: " + flightNumber[i] + "<br />");
       document.write("Terminal: " + terminal[i] + "<br />");
       document.write("Gate: " + gate[i] + "<br />");
       document.write("If your flight departure time is 1/2 hr from now, please proceed to gate. <br/>");
       document.write("Thank you for choosing our airline. Have a safe and pleasnat trip. <br/>");
}//flightInof()

//define flight data
airline = ["Lufthanza", "Swiss Air", "USAir", "Delta", "British Airways", "Air France"];
flightNumber = [356, 89, 1230, 952, 513, 910];
terminal = ["E", "D", "A", "C", "B", "F"];
gate = [5, 10, 3, 7, 1, 8];

//traveler flight
input = prompt("Please, select your flight numer: 356, 89, 1230, 952, 513, or 910", "356");
flightInfo(input);
-->

</script>
</head>
<body>
</body>
</html>

0 0
Add a comment Improve this question Transcribed image text
Answer #1

<html>
<head>
<title>Flying from Boston</title>
<script language="javascript">

<!-- hide script away from browsers
function flightInfo(got) {
   //obtain flight info
   var index;
   for (i=0; i<8; i++) {
       if (got == flightNumber[i])
       {
           index=i;
           break;
       }
   }//for
   if(index!=undefined)
   {
       //print results
       document.write("Here is your flight info:<br />");
       document.write("Airline: " + airline[i] + "<br />");
       document.write("Flight Number: " + flightNumber[i] + "<br />");
       document.write("Terminal: " + terminal[i] + "<br />");
       document.write("Gate: " + gate[i] + "<br />");
       document.write("Departure Time: " + departure_time[i] + "<br />");
       document.write("If your flight departure time is 1/2 hr from now, please proceed to gate. <br/>");
       document.write("Thank you for choosing our airline. Have a safe and pleasnat trip. <br/>");
   }
   else
   {
       alert('flight number not found ');
   }
}//flightInof()

//define flight data
airline = ["Lufthanza", "Swiss Air", "USAir", "Delta", "British Airways", "Air France","United","AA"];
flightNumber = [356, 89, 1230, 952, 513, 910,123,456];
terminal = ["E", "D", "A", "C", "B", "F","G","H"];
gate = [5, 10, 3, 7, 1, 8,2,3];
departure_time=["0800A", "1135P","0800A", "1135P","0800A", "1135P","0800A", "1135P"];

//traveler flight
input = prompt("Please, select your flight numer: 356, 89, 1230, 952, 513, or 910", "356");
flightInfo(input);
-->

</script>
</head>
<body>
</body>
</html>

Add a comment
Know the answer?
Add Answer to:
Please modify the follow source code to also include the following: 1. Add two more flights...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT