Utiliser la boucle ‘do while’ pour obténir l’entrée clavier de l’utilisateur

Author:


{filelink=4632}


import java.util.Scanner;

public class MainClass {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int bank = 1000;
    int pari;

    do {
      System.out.print("Enter your pari: ");
      pari = sc.nextInt();
    } while ((pari <= 0) || (pari > bank));
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *