38 lines
977 B
Java
38 lines
977 B
Java
|
import java.awt.*;
|
||
|
import javax.swing.*;
|
||
|
import java.awt.event.*;
|
||
|
import java.util.*;
|
||
|
import java.io.*;
|
||
|
|
||
|
public class Devinette{
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
Random rand = new Random();
|
||
|
int aleatoire = (rand.nextInt()%100);
|
||
|
if(aleatoire < 0){
|
||
|
aleatoire = -aleatoire;
|
||
|
}
|
||
|
int n=0;
|
||
|
String lec="";
|
||
|
InputStreamReader itr = new InputStreamReader(System.in);
|
||
|
BufferedReader bfr = new BufferedReader(itr);
|
||
|
for(int i=0;i<5;i++){
|
||
|
try{
|
||
|
lec = bfr.readLine().trim();
|
||
|
}catch(IOException e){
|
||
|
System.out.println("Erreur de lecture");
|
||
|
}try{
|
||
|
n = Integer.parseInt(lec);
|
||
|
}catch(NumberFormatException e){
|
||
|
System.out.println("Vous devez choisir un nombre");
|
||
|
} if (n == aleatoire){
|
||
|
System.out.println("Vous avez gagner!");
|
||
|
break;
|
||
|
}else if(n < aleatoire){
|
||
|
System.out.println("Plus grand!");
|
||
|
}else{
|
||
|
System.out.println("Plus petit!");
|
||
|
}
|
||
|
} System.out.println("Le nombre secret etait: "+aleatoire);
|
||
|
}
|
||
|
}
|