You are on page 1of 2

package AS;

import java.util.Scanner;

public class cGaleatorio {


int r;

public cGaleatorio(){
}

public int aleatorio(){


r=(int)(Math.random()*10);
return r;
}

public int aleatorioRango(int li,int ls){


int r;
r=(int)(Math.random()*(ls-li))+li;
return r;
}

public int aleatorioGanador(){


int r;
r=((int)(Math.random()*10))*1111111;
return r;
}

package AS;

import java.util.Scanner;

public class Leer {

char a;String b;int c;long d;


static Scanner teclado;

public Leer() {
teclado = new Scanner(System.in);
}

public char lee_caracter() {


a=teclado.next().charAt(0);
return a;
}

public String lee_cadena () {


b=teclado.nextLine();
return b;

public int lee_entero() {


c=teclado.nextInt();
return c;
}

public long lee_largo() {


teclado = new Scanner(System.in);
d=teclado.nextInt();
return d;
}

package AS;
import java.util.Scanner;

public class Metodo_Principal {

static Leer teclado=new Leer();

public static void main(String[] args) {


int r; // 0-9 y 77777777 GANADOR
int li,ls; // ALEATORIO ENTRE DOS NUMEROS
char rpta;

//COMBINACION CREA ALEATORIO 0-9 Y OTRO PARA 77777777


do {
cGaleatorio oa=new cGaleatorio();
r=oa.aleatorio(); //rango 0-9
System.out.print("aleatorio: "+r);

r=oa.aleatorioGanador();//rango 111111-777777
System.out.print("aleatorio: "+r);
if(r==7777777)
System.out.println("GANASTE PELOTUDO");
else System.out.println("PERDISTE NIUU JAJAJAJA");

System.out.print("\n Continuar<s/n>: ");


rpta=teclado.lee_caracter();
}while(rpta!='n');

//PARA UN RANGO DE NUMEROS(TIENE SALIR DEL ANTERIOR "n"

System.out.println("Aleatorios en un rango: ");


cGaleatorio oa=new cGaleatorio();
System.out.print("Limite inferior: ");
li=teclado.lee_entero();
System.out.print("Limite superior: ");
ls=teclado.lee_entero();
for(int i=1;i<=5;i++) {
r=oa.aleatorioRango(li,ls);
System.out.print(r+", ");
}
}

You might also like