Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: need help with a loop for class...

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Thanked 0 Times in 0 Posts

    Default need help with a loop for class...

    Heres the program description the instructor gave us for class...

    Program Description: Write a program that finds the factorial of a value entered by the user. To calculate 12! (12 factorial) for example the program should calculate the value of

    1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12.

    The program should continue processing numbers until the user inputs a zero. Be sure not to process the terminal value (zero).

    When you are finished submit the completed program to your instructor.

    and here is the code ive got so far
    import java.io.*;
    import java.util.Scanner;
    public class Prog162a
    	public static void main(String args[])
    		System.out.println("Enter a Number [Zero to quit]");
    		Scanner a = new Scanner(System.in);
    		int z = 0;
    		int b = 0;
    		int aa = a.nextInt();
    		while (aa<=aa * 12 +1)
    			b = aa*1;
    			b = aa*2;
    		System.out.println("The value of " + aa +"! is" + b);	
    the think im having trouble with is getting the numbers to multiply differently each time and having the user cut it off in time. Could you help me out please

  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Thanked 619 Times in 561 Posts
    Blog Entries

    Default Re: need help with a loop for class...

    Suggestion: take a look at for-loops.

Similar Threads

  1. need to make basic class and implementation class (base class without void main)
    By javanewbie101 in forum Object Oriented Programming
    Replies: 1
    Last Post: September 19th, 2012, 08:03 PM
  2. create a test class (main method) to start(run) the class in Java
    By curious725 in forum Java Theory & Questions
    Replies: 5
    Last Post: August 1st, 2012, 03:21 AM
  3. Replies: 3
    Last Post: June 17th, 2012, 06:22 PM
  4. [SOLVED] Please help with my while loop that turned into infinite loop!
    By Hazmat210 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: March 10th, 2012, 10:22 PM
  5. Converting a while loop to a for loop and a for loop to a while loop.
    By awesom in forum Loops & Control Statements
    Replies: 3
    Last Post: February 26th, 2012, 07:57 PM