Two spots in my code not working as enteneded if anyone could help tell me were im going wrong would be grateful in one spot it seems to be skipping threw my if statement and the other is not updating on my counter at the end
package roulette; import java.util.*; public class Roulette { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); Scanner scan1 = new Scanner(System.in); Scanner scan2 = new Scanner(System.in); char userinput; char bet; int howmuch; int odds; int iamount =500; int betnum=0; int additional=0; int amountholder=0; int numholder=0; int wins=0; int lose=0; int newcash=0; String s; Random rand =new Random(); int value=0; int[] arr = new int[value]; int[] occurrences = new int[100]; System.out.println("Enter Wheel Size/odds"); odds=scan.nextInt(); do { System.out.println("Do you want to play?"); System.out.println("Type: b to bet"); System.out.println("Type q to quit"); userinput = scan1.nextLine().charAt(0); if (userinput== 'b') { System.out.println("How much do you want to bet?(1-"+ iamount + ")"); howmuch = scan.nextInt(); System.out.println("You bet"+" " + howmuch + "$"); if (howmuch> iamount) { System.out.println("You bet to much"); } else { System.out.println("What number do you want to bet on ?" +"1-" +(odds) ); betnum= scan.nextInt(); if (betnum> odds) { System.out.println("You choice is out of bounds"); } else { System.out.println("You bet on"+" "+ betnum); System.out.println("Do you want to bet on another number?"); System.out.println("If yes type: a"); System.out.println("To spin type: s"); bet = scan1.nextLine().charAt(0); 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) {}; //for some reason i cant get this to go threw this amountholder= howmuch* arrayString.length; } if (amountholder>iamount) { System.out.println("You bet to much"); } else { int numholder1 = rand.nextInt(odds) + 1; int[] array = results; 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 + "$"); iamount=newcash++; System.out.println("Type: b to bet"); System.out.println("Type q to quit"); userinput = scan1.nextLine().charAt(0); } if(bet == 's'); { numholder = rand.nextInt(odds) + 1; System.out.println("You got" + numholder); if (numholder == betnum|| numholder==additional) { wins++; newcash=iamount +(howmuch* (odds-1)); value=numholder; System.out.println("Congratz you Won" + " "+ (howmuch* (odds-1))); } else { newcash= (iamount-howmuch); lose++; System.out.println("Sorry you lost" +" " + howmuch); } System.out.println("You now have "+ newcash + "$"); iamount=newcash++; } } } } } } while(userinput != 'q'); System.out.println("Wins:"+ " "+ wins + "Losses :"+ " "+ lose); System.out.println(""); // should be my updater but its getting bypassed donno why for (int a : arr) { occurrences[a]++; System.out.println("Picks"+occurrences[a]++);} scan.close(); scan1.close(); scan2.close(); if(iamount>500) { System.out.println("Net gains :"+ (iamount-500)); } else { System.out.println("Net losses :" + (500 -iamount)); } }}
sample output :
Enter Wheel Size/odds
2
Do you want to play?
Type: b to bet
Type q to quit
b
How much do you want to bet?(1-500)
12
You bet 12$
What number do you want to bet on ?1-2
1
You bet on 1
Do you want to bet on another number?
If yes type: a
To spin type: s
// this is were i need the help when you hit a do you need to throw each extra bet into an array or can you use some type of if statement?
To spin type: s
s
You got1
Congratz you Won 12
You now have 512$
You chose to quit
Do you want to play?
Type: b to bet
Type q to quit
q
Wins: 1Losses : 0
// this is were i need the counter to say 2 came up 3times or however many times your spinned till u quit
Net gains :12