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

Thread: Donno why its not being checked against the array seem to skipp to the follow on if statement 's" of just spinning

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Donno why its not being checked against the array seem to skipp to the follow on if statement 's" of just spinning

    if (bet == 'a'|| bet == 's')
     
    										{
     
    											if (bet == 'a')
    											{ 
     
    												System.out.println("If you bet a number leave a space between each number");
    												s=scan2.toString();
    												String arrayString[] = s.split("\\s+"); 
     
     
    												String[] items = s.split("\\s+");
     
    												int[] results = new int[items.length];
     
    												for (int i = 0; i < items.length; i++) 
    												{
     
    												    try {
    												        results[i] = Integer.parseInt(items[i]);
    												    } catch (NumberFormatException nfe) {};
     
     
    											amountholder= howmuch* arrayString.length;
    												}			
    														if (amountholder>iamount)
    															{ 
    																System.out.println("You bet to much");	
    															}	
     
    															else {
    															int numholder1 = rand.nextInt(odds) + 1;		
    															int[] array = results;
    																	int value =numholder;
     
    																	int index = Arrays.asList(array,betnum).indexOf(numholder);
    																	System.out.println("You got" + numholder1);
    																	if(index>0);
    																	{      
    																		wins++;
     
    																		newcash=iamount +(howmuch* (odds-1));
     
    																		System.out.println("Congratz you Won" + " "+ (howmuch* (odds-1)));
    																	}                                      
     
    																	if(index<0) 
    																	             {
    																		newcash= (iamount-howmuch);
    																		lose++;
    																		System.out.println("Sorry you lost" +" " + howmuch);
     
    																	              }                
    																	}
     
    										System.out.println("You now have "+ newcash + "$");
     
    										System.out.println("Type: b to bet");
    										System.out.println("Type q to quit");
    										userinput = scan1.nextLine().charAt(0);


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,737
    My Mood
    Mellow
    Thanks
    233
    Thanked 708 Times in 694 Posts

    Default Re: Donno why its not being checked against the array seem to skipp to the follow on if statement 's" of just spinning

    Please provide a description (besides the thread title) of what you need help with. What's the code doing or not doing, provide a sample run if possible, and/or provide runnable code that demonstrates the problem.

    Figuring out what you're asking is harder than helping you with Java. You need to turn that around.

  3. #3
    Junior Member amitection's Avatar
    Join Date
    May 2014
    Location
    India
    Posts
    24
    My Mood
    Busy
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: Donno why its not being checked against the array seem to skipp to the follow on if statement 's" of just spinning

    Could you please Indent your code properly. Its very difficult to read your code & as Greg said about the description.

Similar Threads

  1. Trying to get an "if" statement to work in a "for loop".
    By JAKATAK in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 1st, 2013, 11:16 PM
  2. "Program execution skips the "if" statement"!
    By antony1925 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 7th, 2012, 07:15 AM
  3. Need help with a "missing return statement"
    By guppy507 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 13th, 2011, 08:00 PM
  4. using if statement on string System.getProperty("os.name") not working
    By sauyon in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 29th, 2011, 12:09 PM
  5. first itteration of "for" statement acts differntly to all the rest, why?
    By SPACE MONKEY in forum Java Theory & Questions
    Replies: 4
    Last Post: March 1st, 2011, 10:06 AM