Java - programacion con if

 
Vista:

programacion con if

Publicado por Alondra (1 intervención) el 12/11/2011 23:32:01
escribe un programa que pida dos numeros enteros y que escriba si
el mayor es mitiplo del menor
utilizando if else

Por ejemplo
escribe un numero 48
escribe otro numero 6
48 es multiplo de 6

me pueden ayudar por favor :) me urgee..!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

programacion con if

Publicado por Renzo (232 intervenciones) el 14/11/2011 16:29:28
Hola Alondra, esta es la solución:


//////////////////////////////////////////////////////////////
mport java.io.BufferedReader;
import java.io.InputStreamReader;

/**
*
*/

/**
* @author www.imagineanddo.com
*
*/
public class Ejemplo7 {

/**
* @param args
*/
public static void main(String[] args) {
try{
System.out.print("Ingrese el primer número:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int intNum1 = Integer.parseInt(br.readLine());
System.out.print("Ingrese el segundo número:");
br = new BufferedReader(new InputStreamReader(System.in));
int intNum2 = Integer.parseInt(br.readLine());

if((intNum1%intNum2)==0){
System.out.print(intNum1 + " es múltiplo de "+intNum2);
}
else{
System.out.print(intNum1 + " no es múltiplo de "+intNum2);
}
}
catch(Exception e){

}
}

}


//////////////////////////////////////////////////////////////


Saludos

Espero haberte ayudado

Te invito a visitar mi web: http://www.imagineanddo.com
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

programacion con if

Publicado por Renzo (232 intervenciones) el 14/11/2011 17:15:05
Correción



////////////////////////////////////////////////////

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
*
*/

/**
* @author www.imagineanddo.com
*
*/
public class Ejemplo7 {

/**
* @param args
*/
public static void main(String[] args) {
try{
System.out.print("Ingrese el primer número:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int intNum1 = Integer.parseInt(br.readLine());
System.out.print("Ingrese el segundo número:");
br = new BufferedReader(new InputStreamReader(System.in));
int intNum2 = Integer.parseInt(br.readLine());

if((intNum1%intNum2)==0){
System.out.print(intNum2 + " es múltiplo de "+intNum1);
}
else{
System.out.print(intNum2 + " no es múltiplo de "+intNum1);
}
}
catch(Exception e){

}
}

}


////////////////////////////////////////////////////



Saludos

Espero haberte ayudado

Te invito a visitar mi web: http://www.imagineanddo.com
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar