CSci 1101 Lab 4. Due Tuesday, Feb. 24 at 11:59pm

Work in groups of two.

Fixing the time problem (5 points)

Fix the time issue in cascading if/else exercise: make sure that it prints an error message for invalid times, i.e. $hour < 0 and $hour > 23.

If/else exercise (7 points)

Do the exercise on conditionals: at the end of this page.

Loops exercise (8 points)

Write a program that uses php function rand() to simulate a roll of a six-sided die. Write a loop to find 5 random rolls, print them out, add them all together by keeping a running total, and display the sum.
Some hints: start by writing a loop to repeat the roll of a die 5 times. In the loop store the die value in a variable and print out the variable. Once you get this to work, think of how you would find the sum. You need an extra variable to accumulate the sum. Think of what that variable should be before the loop and how it changes in the loop.

To submit

Just save the two files on csci1101sp09 or, if using remote access, upload them to csci1101sp09. Send me an e-mail when done. Both group partners should be on CC list for this.


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.