Sunday, March 12, 2006

Classwork/ Homework

No talking in class.

Include relevant comments with the programs. You are to select three of the following five.

1. Write a PHP program that compares the length of two words and returns which word is longer. strlen($string) is the most efficient and effective way to do this. Look at the code here.

2. Write a PHP program that compares a random number generated by the computer

srand(time());
$random = (rand()%9);
?>
between one and nine with a number entered from a user. The program must request the user to enter the number again and again until the user enters the same number as the program found. There are many ways to accomplish this.

3. Write a program that uses a for loop to display the first nine numbers that are divisible by three. Think about how many times this loop will need to run...

4. Write a program that asks the user for the radius of a circle and the length of a square. Your program will return the area of both and then a message telling the user by how much the larger of the two is than the smaller. use the squarearea.php program we wrote in class.

5. Write a program that requires the user to enter any word they desire. Store the word in a variable and if any letter in the word is 't' or 'v', return the string "INVALID WORD!"

You can request help via email but you may not discuss this work with other students. This is not a collaborative assignment. I will not waste class time by TALKING about such work. I've done too much it seems.

Due Wednesday.

Title your paper:

Last name, First name
Individual Fourth Nine Weeks PHP Assignment Number 1
Today's date

Before your code include the question. Only code that works will get full credit.

0 Comments:

Post a Comment

<< Home