如果数据无效,请使用在do-while循环主体中设置的布尔变量
/* 来自 nowjava.com - 时 代 Java*/ import java.util.Scanner; public class GetABet3{ static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int bank = 1000; int bet; boolean validBet; System.out.println ("You can bet between 1 and " + bank); do { System.out.print("Enter your bet: "); bet = sc.nextInt(); validBet = true; if ( (bet <= 0) || (bet > bank) ){ validBet = false;