CS 1401, Quiz #6

Date: Monday, February 25, 2008
Name: ____________________________________________________________
Class section MWF 8:30 am

1. For each of the following topics, write "yes" or "no" depending on whether this topic is covered in Chapter 6, the chapter that you were supposed to read before the class:

object oriented design

Graphical User Interface

JFrame class

action events

2. Write a code that uses a for-loop to compute the factorial n! of a given number n, i.e., to multiply all the integers from 1 to n. Do not worry about reading this number or printing the results, assume that the number is there.

 
 
 
 
 
 
 
 
 

3. Write a similar code, but using the while loop.

 
 
 
 
 
 
 
 
 
 
 
 

4. For extra credit: Explain the difference between while- and for-loops. When is it better to use while loops and when for loops? Based on your explanation, what is better for computing the factorial of n?