java - How to end a loop when the value is 0? -
how loop go infintly have end when value reaches 0? want process end when int money reaches 0. not familiar loops sorry if question dumb.
system.out.println(list.get(0).array[3]); (int = 10; <= 1; = - money) { system.out.println("enter in vaule want bet out of $" + money + ""); string moneyvalue = input.next(); int = integer.parseint(moneyvalue);// user input // amount of money want // bet int x = money;// total money if (i > x) { system.out.println("please enter acceptable value 1-" + x); } if (i <= x) { system.out.println("which horse want win, enter in 1-5"); string horsechoice = input.next(); int randomhorse = (int) (math.random() * 5 + 1); int horsechoice1 = integer.parseint(horsechoice); system.out.println(randomhorse); if (horsechoice1 == randomhorse) { system.out.println("you win"); money = x + i; system.out.println("you have $" + money + " remaining."); } else if (horsechoice1 > 5) { system.out.println("sorry try again."); } else { system.out.println("you lose"); money = x - i; system.out.println("you have $" + money + " remaining."); } } }
you can declare in loop
for (int = 10; <=1, money > 0; = - money) {...
Comments
Post a Comment