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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 4 of 4

Thread: Newbie needing a little help

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    8
    My Mood
    Tired
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Newbie needing a little help

    I'm having problems getting these loops to work properly All i need is a way to end the loops properly and make them repeatable after a single user input.
    import java.util.*;
    public class Core {
     
    		public static void main(String[] args) 
    		{
     
    			String Boss;
    			String Weapon;
    			String Character;
    			String[] Bosses = {"Nine Toes","Bone Head","Roid Rage Psycho","Sledge","Krom","Taylor Kobb","Rakk Hive","Hanz and Franz","Baron Flynt","Master McCloud","Scar","Moe","Marley","Skagzilla","Mothrakk","Reaver","Slither","Rakkinishu","One-Eyed Jack","Helob","WidowMaker","Skrappy","Bleeder","King Aracobb","Queen Tarantella","Hank Reiss","Pumpkinhead","Whiskey Wesely","Bigfoot","Redjack","Jackie O' Callahan","Franken Bill","Mr. Shank","General Knoxx","Hera","Minerva","Chaz","Motorhead","Skyscraper","Ajax","Ceresia","Helicon","Cluck-Trap","D-Fault"};
    			String[] Nodlc = {"Nine Toes","Bone Head","Roid Rage Psycho","Sledge","Krom","Taylor Kobb","Rakk Hive","Hanz and Franz","Baron Flynt","Master McCloud","Scar","Moe","Marley","Skagzilla","Mothrakk","Reaver","Slither","Rakkinishu","One-Eyed Jack","Helob","WidowMaker","Skrappy","Bleeder","King Aracobb","Queen Tarantella"};
    			String[] Weapons = {"Pistol","Shotgun","Sniper","Rifle","Machine Gun","Rocket Launcher","Eridian Weapon"};
    			String[] Char = {"Roland","Lilith","Mordecai","Brick"};
    			Random variable = new Random();
    			Scanner keyboard = new Scanner(System.in);
    			System.out.println("Welcome to the Borderlands Challenge Generator.");
    			System.out.println("Include DlC? (Use 0 for No, 1 for Yes).");
    			int User = keyboard.nextInt();
     
    				if (User == 1)
    					{
    						Boss = Bosses[variable.nextInt(44)];
    					}
    				else
    					{
    						Boss = Nodlc[variable.nextInt(25)];	
    					}
    				Weapon = Weapons[variable.nextInt(7)];
    				Character = Char[variable.nextInt(4)];
    				System.out.println("Kill " + Boss + " With " + Character + " Using Only a " + Weapon + " In " + variable.nextInt(300) + " Minutes." );
    				System.out.println("Create New Challenge? (1= yes 0= no)");
    				int Repeat = keyboard.nextInt();
     
    				while (Repeat == 1)
    				{
     
    					Weapon = Weapons[variable.nextInt(7)];
    					Character = Char[variable.nextInt(4)];
    					System.out.println("Kill " + Boss + " With " + Character + " Using Only a " + Weapon + " In " + variable.nextInt(300) + " Minutes." );
    					System.out.println("Create New Challenge? (1= yes 0= no)");
    					break;
    				}
    				}
    		}


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Newbie needing a little help

    You may wish to describe your problem in greater detail. You state you're having problems -- what problems are you having? Compilation problems? Exceptions? Program misbehavior? Herpes? And just what is this code supposed to be trying to do? These details are likely to be very important to us.

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    8
    My Mood
    Tired
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Newbie needing a little help

    Ok what I'm writing is along the lines of a random number generator with multiple variables. What I'd like to do is be able to ask the user if they would like to generate a new list of variables at the end of the program. The trouble is everything I've tried doesn't seem to work. All I want to do is be able to reuse a loop if the user wants to generate a new set.

  4. #4
    Junior Member
    Join Date
    Aug 2012
    Posts
    8
    My Mood
    Tired
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Newbie needing a little help

    Fixed it! All i had to do was write in a buffer in the repeat loop!

Similar Threads

  1. beginer in java .. needing help
    By Kandarp in forum Java IDEs
    Replies: 4
    Last Post: August 31st, 2012, 08:05 AM
  2. NEEDING HELP UNDERSTANDING A CODE FROM THREE CLASSES!!!
    By BlackShadow in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 5th, 2012, 09:29 AM
  3. New student needing help!
    By newstudent in forum Object Oriented Programming
    Replies: 2
    Last Post: January 30th, 2012, 12:49 AM
  4. Java and programming newbie needing help
    By speedmaster in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 8th, 2010, 07:57 AM
  5. [SOLVED] [Method] needing some help
    By Perplexing in forum Object Oriented Programming
    Replies: 4
    Last Post: December 2nd, 2010, 05:03 PM

Tags for this Thread