2 Replies - 295 Views - Last Post: 08 May 2014 - 08:55 AM Rate Topic: -----

#1 iamlost123  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-May 14

Roulette wheel not working completely

Posted 07 May 2014 - 11:39 AM

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);
	


Quote

//this is were its going wrong if i just do a straight "spin" it works but when i try and add additional bets into an array for future comparrison it simply kicks out to my "do" statements says you have quit and acts like i simply hit spin

                                                                           
                                                                      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("");	

				
[quote]// should be my updater but its getting bypassed donno why[/quote]				
				
				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));	
				}
	
	}}					
	

	
	


Is This A Good Question/Topic? 0
  • +

Replies To: Roulette wheel not working completely

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2815
  • View blog
  • Posts: 11,916
  • Joined: 20-September 08

Re: Roulette wheel not working completely

Posted 08 May 2014 - 06:00 AM

Your code is badly posted and too atomised. Post the whole thing and annotate the parts you want to draw attention to.
Was This Post Helpful? 0
  • +
  • -

#3 NormR  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 54
  • Joined: 25-December 13

Re: Roulette wheel not working completely

Posted 08 May 2014 - 08:55 AM

Also posted at: http://www.javaprogr...ng-updated.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1