## CSci 1101 Problem set 3. Due Tuesday March 14 at 10pm

Testing and submitting your programs.

### Question 1

Given the first array example (colors and fruit), create a table with the opposite order of elements (banana, orange, apple) WITHOUT changing the order of elements in the arrays.
Here is the starting code:
``````
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
PHP arrays
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 2/21/06
-->
<?php
// DO NOT CHANGE THE ORDER OF ELEMENTS IN THESE ARRAYS
\$colors = array("red", "orange", "yellow");
\$fruit = array("apple", "orange", "banana");
\$td_style = "width: 75px; height: 30px; text-align: center";
?>
<html>
<head>
<title>
Using arrays to generate a table
</title>
</head>
<body>
<h3>What would you like for breakfast?</h3>

</body>
</html>
``````

### Question 2

You are given a program with two arrays: an array of student names and an associative array that assigns a numeric grade to each student:
``````
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 2/25/06
-->
<?php
\$students = array("Joe Smith", "Jane Brown", "Bob Green",
"Julia Anderson", "Mary Andrews",
"Peter Black");
\$scores = array("Joe Smith" => 75, "Jane Brown" => 88,
"Bob Green" => 96, "Julia Anderson" => 93.5,
"Mary Andrews" => 67, "Peter Black" => 89);
?>
<html>
<head>
<title>
Homework Question 2
</title>
</head>
<body>
<h2>Grade list</h2>

</body>
</html>
``````
Question 2.1 Write a program that creates a table with one row per student, the student's name in one column and their grade in the other column. Test the program and save it away before moving on to the next question.
Question 2.2 Change the program so that it shows scores above 90 in boldface and scores below 70 in red. Test your program. Then change the scores in the array and test it again. Save the solution before moving on to the next question.
Question 2.3 Add the third column to the table for the letter grade. Compute the letter grade as follows: scores of >= 90 convert to A, scores between 80 (including) and 90 (not including) convert to B, scores between 70 (including) and 80 (not including) convert to C, scores between 60 (including) and 70 (not including) convert to D, and below 60 convert to F. Test your program with different scores.
Question 2.4 After the table print out how many students who are passing the course (i.e. have grades of D and above). You don't need to print the names.

### Question 3

Write a program that has an array of two colors (a lighter one first, then a darker one), for instance
``````
\$colors = array("lightgreen", "darkgreen");
``````
The program draws a chessboard as a table, alternating the cell background between the two colors. A chessboard is 8-by-8 squares, starting with the lighter color as the top left cell. Make sure that the table cells are squares (i.e. you need to set width and height).

### Question 4

Change the program in Question 6 of Problem set 2 to use loops (you will need a loop for columns inside a loop for rows). The program should create the same table.

### Submitting your code

Make sure all your files are uploaded to rynite, send me an e-mail with the file names and locations when done. It's OK to submit only the final version of question 2 if everything is working right, but if something is not working as you expected then please submit separate parts of it separately.

This page is a part of CSci 1101 course web site.

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.