i have a problem with this program. Please help. The problem is in the last if statement. I get the following error:
- operator % cannot be applied to Wheel, int
The below is the program, and after it is the class
this is the classCode:import cs1.Keyboard; public class Roulette { public static void main (String [] args) { Wheel spin= new Wheel(); double initialmoney= 100; System.out.println("Welcome to Roulette!"); System.out.println("You start off with $" + initialmoney + "\n Please select how much you would like to bet: "); int bet= Keyboard.readInt(); System.out.println("Where would you like to place your bet? (Enter Designated Number) \n\t Evens=1 \n\t Odds=2 \n\t Blacks=3 \n\t Reds=4 \n\t First 12=5 \n\t Second 12= 13 \n\t Third 12= 14 \n\t -1 or 0=15 \n\t or a Specific Number: "); int guess= Keyboard.readInt(); if(guess==1) { if(spin%2==0);}}}
Code:import java.util.Random; public class Wheel { private double spin; public Wheel () { getwheel (); } public void getwheel () { spin= (double) (Math.random() * 36); } public String toString() { String wheelSpin= ""; if (spin==1) wheelSpin = "1- Red"; else if (spin==2) wheelSpin = "2- Black"; else if (spin==3) wheelSpin = "3- Red"; else if (spin==4) wheelSpin = "4- Black"; else if (spin==5) wheelSpin = "5- Red"; else if (spin==6) wheelSpin = "6- Black"; else if (spin==7) wheelSpin = "7- Red"; else if (spin==8) wheelSpin = "8- Black"; else if (spin==9) wheelSpin = "9- Red"; else if (spin==10) wheelSpin = "10- Black"; else if (spin==11) wheelSpin = "11- Black"; else if (spin==12) wheelSpin = "12- Red"; else if (spin==13) wheelSpin = "13- Black"; else if (spin==14) wheelSpin = "14- Red"; else if (spin==15) wheelSpin = "15- Black"; else if (spin==16) wheelSpin = "16- Red"; else if (spin==17) wheelSpin = "17- Black"; else if (spin==18) wheelSpin = "18- Red"; else if (spin==19) wheelSpin = "19- Red"; else if (spin==20) wheelSpin = "20- Black"; else if (spin==21) wheelSpin = "21- Red"; else if (spin==22) wheelSpin = "22- Black"; else if (spin==23) wheelSpin = "23- Red"; else if (spin==24) wheelSpin = "24- Red"; else if (spin==25) wheelSpin = "25- Red"; else if (spin==26) wheelSpin = "26- Black"; else if (spin==27) wheelSpin = "27- Red"; else if (spin==28) wheelSpin = "28- Black"; else if (spin==29) wheelSpin = "29- Black"; else if (spin==30) wheelSpin = "30- Red"; else if (spin==31) wheelSpin = "31- Black"; else if (spin==32) wheelSpin = "32- Red"; else if (spin==33) wheelSpin = "33- Black"; else if (spin==34) wheelSpin = "34- Red"; else if (spin==35) wheelSpin = "35- Black"; else if (spin==36) wheelSpin = "36- Red"; String wheelresult = (wheelSpin); return wheelresult; } }


Reply With Quote


Bookmarks