Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

While loop!

843789Sep 7 2009 — edited Sep 9 2009
Here is my code:
import java.util.Scanner;
public class MyRandom {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        double r, total;

        r = ((r * 25173) + 13849) % 65536;

       while(input == 'y' || input == 'Y') {
       Scanner keys = new Scanner(System.in);
       System.out.println("Enter a number from 0-65,535");
       double number = keys.nextDouble();
       keys.nextLine();

       total = number * r;

       System.out.println(total);
       System.out.println("If you would like another random number type y" +
               " for yes or n for no?");
       String input = keys.nextLine();
         }
        }
}
I know it's close, but I want the while loop to loop as many times as the user wants, but forgot if I need to put n or y in the parameters for the while loop. Also it says that the parameters for input in the while loop can't be found in netbeans, I figure this is because input doesn't show up untill the end of the loop. How can I make this work? I tried to google this but didn't find what I was looking for. Thank You for the Help!

Paradox(>")>

Edited by: paradox6996 on Sep 7, 2009 10:56 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2009
Added on Sep 7 2009
29 comments
203 views