tuchman
11-22-2010, 12:25 AM
Hi, I am stumped with this question and hope someone can help me. I am very new to javascript and am having a lot of trouble. Here is the question I am trying to solve along with the script that I have so far. Can someone please help me out, thanks!!
Question:
In a Prompt Box, ask the user “When do you plan to come to the
Hatch to eat?” and expect the user to provide the time in military time (e.g., 0400 =
4 am and 1700 = 5 pm). If the hour is between 7 am and 10:59 am (0700-1059),
reply using an Alert Box “The Hatch is Serving Breakfast!” If the hour is between
11 am and 3:39 pm (1100-15:59), reply “The Hatch is Serving Lunch!” If the hour is
between 4 pm and 10 pm (1700-2200), reply “The Hatch is Serving Dinner!” If the
hour is between 10:01 pm and 11 pm, reply “The Hatch is serving coffee and tea!”
Otherwise reply “The Hatch is closed after 11 pm!”
My Script:
[CODE]<html>
<head>
<script language=javascript>
document.write("<h3>");
var time=prompt("What time is it? (Please enter in military time with no symbols) ","");
if( time < 1600 ){
document.write("The Hatch is Serving Breakfast! ");
}
if( 1600 < time < 1059 > ){
document.write("The Hatch is serving Lunch! ");
}
if( time < 1659 > 2159 ){
document.write("The Hatch is serving Dinner! ");
}
document.write("</H2>");
</script>
</head>
<body>
<input type="button" onclick="show_prompt()" value="Show prompt box" />
</body>
</html>
/CODE]
Question:
In a Prompt Box, ask the user “When do you plan to come to the
Hatch to eat?” and expect the user to provide the time in military time (e.g., 0400 =
4 am and 1700 = 5 pm). If the hour is between 7 am and 10:59 am (0700-1059),
reply using an Alert Box “The Hatch is Serving Breakfast!” If the hour is between
11 am and 3:39 pm (1100-15:59), reply “The Hatch is Serving Lunch!” If the hour is
between 4 pm and 10 pm (1700-2200), reply “The Hatch is Serving Dinner!” If the
hour is between 10:01 pm and 11 pm, reply “The Hatch is serving coffee and tea!”
Otherwise reply “The Hatch is closed after 11 pm!”
My Script:
[CODE]<html>
<head>
<script language=javascript>
document.write("<h3>");
var time=prompt("What time is it? (Please enter in military time with no symbols) ","");
if( time < 1600 ){
document.write("The Hatch is Serving Breakfast! ");
}
if( 1600 < time < 1059 > ){
document.write("The Hatch is serving Lunch! ");
}
if( time < 1659 > 2159 ){
document.write("The Hatch is serving Dinner! ");
}
document.write("</H2>");
</script>
</head>
<body>
<input type="button" onclick="show_prompt()" value="Show prompt box" />
</body>
</html>
/CODE]