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*; i public class AdivinaNum{ p public static BufferedReader entrada = new BufferedReader(new InputStreamReader(; 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 número entre 1 y 100: "); salida.flush(); n = Integer.parseInt(entrada.readLine());} salida.println(" ± Adivinaste el número. Tu número 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 aplicación »"); s } }...
View Full Document

This note was uploaded on 10/29/2009 for the course ITC TC-1002 taught by Professor X during the Spring '09 term at ITESM.

Ask a homework question - tutors are online