ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Clases Scanner Integer Y Ejemplos En JAVA


Enviado por   •  5 de Mayo de 2013  •  6.292 Palabras (26 Páginas)  •  635 Visitas

Página 1 de 26

Permutacion con repeticion = nr

Permutacion sin repetición =

Combinacion sin repetir = Rad = (°’s x PI) / 180

Num Perfecto = 6 es un número perfecto porque sus divisores propios son 1, 2 y 3; y 6 = 1 + 2 + 3. (28, 496 y 8128 y 33 550 336)

public void P( int N ) {

int cuenta = 0;

for ( int j = 1; j <= N; j++ ){

cuenta = 0;

for ( int i = 1; i <= j/2 ; i++ )

if( 0 == j % i )

cuenta += i;

if ( cuenta == j ){

Imprime(j);

}

}

}

public void Imprime( int x ){

System.out.printf("%d = ", x);

for ( int s = 1; s <= x/2; s++ ){

if ( 0 == x%s )

System.out.printf("\t%3d", s);

}

System.out.println("\n");

}

public static void main(){

Scanner escaner = new Scanner(System.in);

System.out.println("");

int numero = escaner.nextInt();

if ( esP(numero) == true ){

System.out.println("ES P");

}

}

public static boolean esP(int numero){

int contador =2;

boolean p=true;

while( (p == true) && (contador!=numero)){

if ( numero % contador == 0){

p = false;

}

contador++;

}

return p;

}

public static void main(String[]args){

int angulo;

int aproximacion;

int cont=1;

boolean bandera=true;

double aux=0;

angulo=Integer.parseInt(JOptionPane.showInputDialog(null,"angle"));

aproximacion=Integer.parseInt(JOptionPane.showInputDialog(null,"iteratos"));

double radian= formula;

while(cont<=aproximacion){

if(bandera==true){

aux=aux+((Math.pow(radian,cont))/Seno.factorial(cont));

bandera=false;

}else{

aux=aux-((Math.pow(radian,cont))/Seno.factorial(cont));

bandera=true;

}

cont=cont+2;

}

JOptionPane.showMessageDialog(null,"el angulo es: "+ angulo + "\n" + "angulo en radianes: " +radian+ "\n" + "el seno del angulo es: " +( Math.round(aux*Math.pow(10,4))/Math.pow(10,4)));

}

public static int factorial(int cont){

int resultado=1;

for(int i=cont;i>0;i--){

resultado*=i;

}

return resultado;

}

public static void main(String[]args){

double focos;

focos=Integer.parseInt(JOptionPane.showInputDialog(null," numero de focos en el pasillo?"));//se guarda el num ero de focos que abra en el pasillo

double vueltasPasillo= Math.sqrt(focos);//sacamos la raiz cuadrada del numero de focos y guardamos en la variable vueltasPasillo

if((int)vueltasPasillo*(int)vueltasPasillo==focos){//casteamos con entero.. y multiplicamos la variable vueltasPasillo por si misma... si el resultado es igual al numero de focos entonces el foco esta encendido.. si no esta apgado

JOptionPane.showMessageDialog(null,"el ultimo foco esta prendido");

} else{

JOptionPane.showMessageDialog(null,"el ultimo foco esta apagado");

}

}

CLASE SCANER

Method Summary

void close()

Closes this scanner.

Pattern

delimiter()

Returns the Pattern this Scanner is currently using to match delimiters.

String

findInLine(Pattern pattern)

Attempts to find the next occurrence of the specified pattern ignoring delimiters.

String

findInLine(String pattern)

Attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.

String

findWithinHorizon(Pattern pattern, int horizon)

Attempts to find the next occurrence of the specified pattern.

String

findWithinHorizon(String pattern, int horizon)

Attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.

boolean hasNext()

Returns true if this scanner has another token in its input.

boolean hasNext(Pattern pattern)

Returns true if the next complete token matches the specified pattern.

boolean hasNext(String pattern)

Returns true if the next token matches the pattern constructed from the specified string.

boolean hasNextBigDecimal()

Returns true if the next token in this scanner's input can be interpreted as a BigDecimal using the nextBigDecimal() method.

boolean hasNextBigInteger()

Returns true if the next token in this scanner's input can be interpreted as a BigInteger in the default radix using the nextBigInteger() method.

boolean hasNextBigInteger(int radix)

Returns true if the next token in this scanner's input can be interpreted as a BigInteger in the specified radix using the nextBigInteger() method.

boolean hasNextBoolean()

Returns true if the next token in this scanner's input can be interpreted as a boolean value using a case insensitive pattern created from the string "true|false".

boolean hasNextByte()

Returns true if the next token in this scanner's input can be interpreted as a byte value in the default radix using the nextByte() method.

boolean hasNextByte(int radix)

Returns true if the next token in this scanner's input can be interpreted as a byte value in the specified

...

Descargar como (para miembros actualizados) txt (24 Kb)
Leer 25 páginas más »
Disponible sólo en Clubensayos.com