Review for Midterm I

HTML, CSS examples

What will be the result of formatting the HTML below with the CSS file that follows?


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>
A sample page.
</title>
<link rel="stylesheet" type="text/css" href="question1.css" />
</head>
<body>
<h1>My little page</h1>
<p class="special">
This is the first part to my page. <strong>Welcome,
everyone!</strong> Some things that I like:
</p>
<ul>

<li class="special">biking</li>
<li>reading</li>
<li><strong>sleeping</strong></li>
</ul>
<p>
I hope you enjoyed <strong>my page!</strong>
</p>

</body>
</html>

The question1.css file:


p, h1 {
	text-align: center;
}

p strong {
	color: #FF0000; /* red */
}

.special {
	font-style: italic;
}

PHP conditionals

Is the following program correct? If nor, please give an example of data for which it gives a wrong result and rewrite the program to fix the issue.


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Conditionals review question
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 3/6/08
-->
<?php
$credits = $_GET["credits"];
?>
<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>
Review question 2
</title>
</head>
<body>
<h2>Does this work correctly?</h2>
<p>
<?php
if ($credits < 30) {
  print "You are a freshman<br />\n";
} else if ($credits < 90) {
  print "You are a junior<br />\n"; 
} else if ($credits < 60) {
  print "You are a sophomore<br />\n";
} else {
  print "You are a senior<br />\n";
}
?>
</p>
</body>
</html>
http://csci1101sp09.morris.umn.edu/~elenam/1101_spring09/review1/review_if_else.php?credits=15

PHP loops

What will be printed by this loop when the input is 4?


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Loops review question
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 3/6/08
-->
<?php
$n = $_GET["input"];
?>
<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>
Review question 2
</title>
</head>
<body>
<h2>What will be printed?</h2>
<p>
<?php
$m = 2;
for ($i = 0; $i < $n; $i++) {
  print "m = $m<br />\n";
  $m = $m * $m;
}
?>
</p>
</body>
</html>
http://csci1101sp09.morris.umn.edu/~elenam/1101_spring09/review1/review_loop.php?input=8

UMM CSci 1101

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.