Discover the answers you need at Westonci.ca, where experts provide clear and concise information on various topics. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.
Sagot :
Answer:
Explanation:
El siguiente algoritmo esta escrito en Java y genera un numero aleatorio. Despues le pide al usario que intente adivinar el numero. Si el usario adivina correctamente entoces le dice que fue correcto y termina el programa. Si no adivina bien entonces dice Incorrecto y le pide otra adivinanza al usario hasta llegar a la tercera adivinanza y se termina el programa.
import java.util.Random;
import java.util.Scanner;
class Brainly{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Random ran = new Random();
int numero = ran.nextInt(20);
for (int x = 0; x <= 2; x++) {
System.out.println("Adivina el numero entre 0 y 20: ");
int respuesta = in.nextInt();
if (respuesta == numero) {
System.out.println("Correcto");
break;
} else {
System.out.println("Incorrecto");
}
}
}
}
![View image sandlee09](https://us-static.z-dn.net/files/d05/1d800cb673be25387b100cedfea7e797.jpg)
Thank you for trusting us with your questions. We're here to help you find accurate answers quickly and efficiently. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.