Click to See Complete Forum and Search --> : Java Problem


Clanxennex
03-24-2007, 04:56 PM
My friend is in a course and he gave me this java problem to solve for him im completely stuck anyone wanna help me out PLEASE!! He wants me to do it but i dont know how can anyone do it for me or help me out

Write a program that will calculate a factorial by using a while loop. The program should have the following structure:

final int UPPER_LIMIT = 100; // this will be changed via
//experiments
do
{
limit = getLimit();
if (limit > 0)
{
factorial = computeFact(limit);
System.out.println(limit + '!= ' + factorial);
}
}while (limit>0);
Notes:
- The internal private methods will need to be static
- the getLimit method should error trap the input to insure it is not negative and that the limit is less than or equal to the UPPER_LIMIT
- the computerFact method should receive the limit as a parameter and should compute and return the factorial value. This method must use a while loop to compute the value (there are easier ways, but use a while).

After your program is running correctly, experiment to find the correct value of UPPER_LIMIT ---- that is, the largest value for which the factorial is correct. Then change the UPPER_LIMIT assignment in your final program.
- Name the class Factorial

LukeJea
03-25-2007, 11:30 AM
This program should work if your computeFact(limit); computes the correct informormation.

You might wanna post the code for the computeFact(x) function.

What errors are you getting

agent_x91
03-26-2007, 06:57 AM
final int UPPER_LIMIT = 100; // this will be changed via
//experiments


I don't quite know what you mean "experiments", but the keyword final and the phrase "this will be changed" really don't go together. :) You can't change the value of a final variable.