Question 1,2,3,4
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<script type="text/javascript">
document.write("<h1>Question 1</h1>");
document.write("Result of 0xab00 + 0xcd = ");
document.write(0xab00 + 0xcd + "<br />");
document.write("Result of 0xff - 0123 = ");
document.write(0xff - 0123 + "<br />");
document.write("<br /><br />"); /* Some Space */
document.write("<h1>Question 2</h1>");
document.write("Result of -4.321 + 55. = ");
document.write(-4.321 + 55. + "<br/>");
document.write("Result of 12e2 - 1e-2 = ");
document.write(12e2 - 1e-2 + "<br/>");
document.write("Result of .5 - 4e-4 = ");
document.write(.5 - 4e-4 + "<br/>");
document.write("<br /><br />"); /* Some Space */
document.write("<h1>Question 3</h1>");
document.write("Result of true * 5 + false * 7 = ");
document.write(true * 5 + false * 7 + "<br/>");
document.write("<br /><br />"); /* Some Space */
document.write("<h1>Question 4 - Create a face</h1>");
document.write("<pre> \"\"\"\"\"\"\"<br />
\"\"\"\"\"\"\"\"\"<br /> --\"\"\" \"\"\"--<br /> <
<.> <.> ><br /> / \\<br />
\\-----/<br /> --\"--<br /></pre>");
document.write("<br /><br />"); /* Some Space */
</script>
</body>
</html>
Question 5
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<p>
Use pop-up boxes to get a name, date of birth (date, month, and year in separate boxes) and
display the name, date of birth, and age on a table.
</p>
<script type="text/javascript">
var name = prompt("Enter name ");
var date = prompt("Enter birth date ");
var month = prompt("Enter birth month ");
var year = prompt("Enter birth year ");
var todate = new Date();
var elapsedYear= todate.getYear();
var currentYear= parseInt(elapsedYear) + 1900;
var age = currentYear - year;
document.write( "<table style=\"border:solid 2px\"'><tr><td>Name<
/td><td>DOB</td><td>Age</td><tr><td>"+ name +
"</td> <td>" + date+"/"+month+ "/" + year +"</td> <td>" + age +
"</td></tr></table>");
</script>
</body>
</html>
Hi Denis and everyone,
ReplyDeleteI wrote it using if - else and month values.
After I read your post I found some samples without using them.
However, some of them have leap year problem and
they look too complicated to understand.
So I stopped my research :P
I will start creating a face(Q4) now ...!
Ciao:D
I see. The values for months are a bit confusing (0 for Jan, 11 for Dec). Unless you used arrays of course.
ReplyDeleteLeap year is not a problem if you use the GetFullYear() function, that returns the year (and all its time attributes).
I don't think that Shanti expects us to give the exact age specific to the month, but the year.
I might be mistaken but I am too lazy to tell people their age using a program. They should know better than me HAHA
I tried to paste my javascript face, but it's not working... :(
ReplyDeleteThank you for your advice, I will check that function after I finish another homework.
ReplyDeleteYou 've already done all homework?! Cool.
I will have a look your website on weekend to get good idea :D
p.s. I created my cat's face. cute.
neko chan!
ReplyDelete