tag:blogger.com,1999:blog-7341750178608116612.post1401113133368068833..comments2024-03-15T16:39:34.032-06:00Comments on EJERCICIOS RESUELTOS: Deitel_Java_6.17 (Determinar si un Entero es Par)hitmontophttp://www.blogger.com/profile/00285449979028749180noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-7341750178608116612.post-28873308626509942682023-09-26T07:36:09.162-06:002023-09-26T07:36:09.162-06:00for(int i=1; i<7; i++){
a=i%2;
// println(&quo...for(int i=1; i<7; i++){<br /> a=i%2;<br />// println("el valor del residuo es ",a);<br /> if(a==0)<br /> println("2% espar,",i);<br /> else<br /> println("%1 es impar,",i);<br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7341750178608116612.post-88788384105940368092017-05-03T12:53:34.291-05:002017-05-03T12:53:34.291-05:00cuando intento compilarlo me sale error, alguien p...cuando intento compilarlo me sale error, alguien podria ayudarme? <br />Anonymoushttps://www.blogger.com/profile/06109847617254923264noreply@blogger.comtag:blogger.com,1999:blog-7341750178608116612.post-73636429431118083682017-05-03T12:52:54.758-05:002017-05-03T12:52:54.758-05:00public class Par {
private int numero;
...public class Par {<br /> private int numero;<br /> <br /> public Par()<br /> {<br /> numero = 1;<br /> }<br /> <br /> /*public Par(int a)<br /> {<br /> numero = a;<br /> }*/<br /> <br /> public void establecerNumero(int a)<br /> {<br /> numero = a;<br /> }<br /> <br /> public int obtenerNumero()<br /> {<br /> return numero;<br /> }<br /> <br /> public String aStringPar()<br /> {<br /> if(obtenerNumero()%2 == 0)<br /> return String.format("El numero "+obtenerNumero()+" es par.");<br /> else<br /> return String.format("El numero "+obtenerNumero()+" no es par.");<br /> }<br />}<br /><br />la prueba Clase ahora <br /><br />import java.util.Scanner;<br />public class pruebaPar {<br /> public static void main(String []args)<br /> {<br /> Scanner sc = new Scanner(System.in);<br /> System.out.printf("Cantidad de numeros a ingresar: ");<br /> int cantidad = sc.nextInt();<br /> <br /> Par par[] = new Par[cantidad];<br /> <br /> for( int i=0; i<par.length ; i++ )<br /> {<br /> System.out.printf("Ingrese un numero entero: ");<br /> int numero = sc.nextInt();<br /> <br /> par[i].establecerNumero(numero);<br /> }<br /> <br /> for( int i=0; i<par.length ; i++ )<br /> {<br /> System.out.println(par[i].aStringPar());<br /> }<br /> }<br />}Anonymoushttps://www.blogger.com/profile/06109847617254923264noreply@blogger.comtag:blogger.com,1999:blog-7341750178608116612.post-21361703682105287162015-07-13T01:23:17.736-05:002015-07-13T01:23:17.736-05:00class NumeroPareImpar {
/**
* @param arg...class NumeroPareImpar {<br /><br /> /**<br /> * @param args the command line arguments<br /> */<br /> public static void main(String[] args) {<br /> <br /> Scanner numero= new Scanner(System.in);<br /> <br /> System.out.print("Introdusca el Primer Numero: ");<br /> int num1=numero.nextInt();<br /> <br /> if(num1%2==0)<br /> System.out.println("el numero "+num1+" es par");<br /> else<br /> System.out.println("el numero "+num1+" es impar");<br /> <br /> <br /> }<br /> <br />}<br />Anonymoushttps://www.blogger.com/profile/09407017650915746988noreply@blogger.com