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
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