go to previous page   go to home page   go to next page

Answer:

Yes. Static methods can call other static methods.

Yes. Static methods pass data to other static methods through parameters.


Factorial (Again!)

flowchart of factorial

Recall factorial from chapter 21 (and likely from many math courses):

N Factorial == 
    N! == N*(N-1)*(N-2)*(N-3)* . . . 4*3*2*1

N must be a positive integer or zero, and 0! is defined to be 1. For example,

 
6! == 6*5*4*3*2*1 == 720
Let us write a program that repeatedly asks the user for N, computes N!, prints it out, and asks for another N. The user signals the end of input by entering a negative value.


QUESTION 3:

The program keeps looping until the user signals the end. What type of loop is this?


go to previous page   go to home page   go to next page