1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
import javax.swing.*;
class JeuNono
{
public static void main(String[] args)
{
Scanner lectureClavier;
int i=(int)(100*Math.random()), nbboucle = 0;
String texteNbLu=
JOptionPane.showInputDialog("un jeu: choisi un nombre entre 1 et 100");
int Nblu = Integer.parseInt(texteNbLu);
if(Nblu != i)
{ System.out.print("tapez un chiffre:");
lectureClavier = new Scanner(System.in);
Nblu = lectureClavier.nextInt();
System.out.print("tapez un chiffre:");
if (Nblu > i)
System.out.print("Trop grand, mon petit!\n");
if (Nblu < i)
System.out.print("Trop petit , mon grand\n");
nbboucle++;
}
System.out.print("Bravo: tu as réussi en " + nbboucle + " fois");
}
} |
Partager