Java Programming Assignment 3

 

This assignment represents 25% of the assessment for the course.

 

1. Write a program Factorial which reads a number N and computes Factorial N.

     The Factorial function is defined as follows:

     Factorial N = N * (N-1) * , ..., 1. For example, Factorial(5) = 5 * 4 * 3 * 2 * 1 = 120

 

2. Write a program Arrow1 which reads a number N and prints a triangle. For example, if N=5, the program should print

 

*

**

***

****

*****

 

3. Write Arrow2 (adapted from Arrow1) which prints, for example, the following when N = 5

 

*

**

***

****

*****

****

***

**

 

4. Write Diamond which prints for N=9

 

        *

      ***

    *****

  *******

*********

  *******

    *****

      ***

        *

 

5. Write Square2 which prints, for example, the following when N=5

 

*****

*      *

*      *

*      *

*****

 

 

     

Deadline: Please submit your answers (5 java file attachments) to me by email by Wednesday 10th January.

 

References:

 

·         Savitch Chapter 3.1-3.4  contains most of the information.

·         Otherwise, a good starting point for tutorial material is http://java.sun.com/docs/books/tutorial/java/index.html

·         Otherwise, use Google to search for "java tutorial"

 

 

 

MR

[20/12/2006]