Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

12/11/23, 13:07 TSUGI - Virtual Judge

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this lic
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package javaapplication17;

import java.util.Scanner;

/**
*
* @author bekkm
*/
public class JavaApplication17 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);


int numeroAleatorio = 39;
boolean endGame, primerIntento;
endGame = primerIntento = false;

while (!endGame) {
System.out.println("Introduzca el numero de intentos: ");
int intentosMaximos = sc.nextInt();
if (intentosMaximos == 0) endGame = true;

while (intentosMaximos != 0) {

System.out.println("Introduce un numero: ");


int intento = sc.nextInt();

if (intento == numeroAleatorio) {
System.out.println("GANASTE");
break;
} else {
if (intento > numeroAleatorio) {
System.out.println("MAYOR");
intentosMaximos--;
} else {
System.out.println("MENOR");
intentosMaximos--;
}
}

if (intentosMaximos == 0) {
System.out.println("PERDISTE");
}

}
}

https://juez-lti.es/mod/codetest/student-home.php?PHPSESSID=c9a2fad069634b714a456fbbecda274f 1/2
12/11/23, 13:07 TSUGI - Virtual Judge

https://juez-lti.es/mod/codetest/student-home.php?PHPSESSID=c9a2fad069634b714a456fbbecda274f 2/2

You might also like