AdivinaNum

AdivinaNum - while(n!=random){ if(n!=random)...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.*; i public class AdivinaNum{ p public static BufferedReader entrada = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter salida = new PrintWriter(System.out, true); p public static void main(String args[]) throws IOException{ p System.out.println(" « inicio de la aplicación »\n"); S String user = ""; int n; int cont = 1; do{ int random = (int)(Math.random()*(101)); salida.print("\nIngresa un número entre 1 y 100: "); salida.flush(); n = Integer.parseInt(entrada.readLine());
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: while(n!=random){ if(n!=random) salida.println("No has adivinado. Intenta de nuevo."); cont++; salida.print("\nIngresa un nmero entre 1 y 100: "); salida.flush(); n = Integer.parseInt(entrada.readLine());} salida.println(" Adivinaste el nmero. Tu nmero de intentos fue: "+cont); cont = 1; salida.println("\n Deseas jugar de nuevo? (s/no)"); user = entrada.readLine(); }while(user.toLowerCase().equals("si")); } salida.println("\n fin de la aplicacin "); s } }...
View Full Document

Ask a homework question - tutors are online