Created
May 17, 2012 21:23
-
-
Save godie007/2721658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.swing.JOptionPane; | |
| public class Ejercicio1 { | |
| private static int metodo(int a) { | |
| int b = 0; | |
| for (int i = 1; i <= a; i++) { | |
| int mod = i*3; | |
| b += mod; | |
| }return b; | |
| } | |
| public static void main(String[] args) { | |
| int a = Integer.parseInt(JOptionPane.showInputDialog("num")); | |
| System.out.println("ES: "+ metodo(a)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.swing.JOptionPane; | |
| public class Ejercicio2 { | |
| private static int metodo() { | |
| int Numero = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el número: ")); | |
| int Cuenta = 0; | |
| Cuenta = 0; | |
| for (int N = 1; N != Numero + 1; N++) { | |
| if (Numero % N == 0) { | |
| Cuenta++; | |
| } | |
| }return Cuenta; | |
| } | |
| public static String metodo2() { | |
| String c1= ""; | |
| if (metodo()==2) { | |
| c1 = "es primo"; | |
| } else { | |
| c1 = "no es primo"; | |
| } | |
| return c1; | |
| } | |
| public static void main(String[] args) { | |
| System.out.println("el resultado " + metodo2()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Ejercicio3 { | |
| public static int Cadena(String cadena,int contador){ | |
| for (int i = 0; i < cadena.length(); i++) { | |
| cadena = cadena.toUpperCase(); | |
| if ( cadena.charAt(i) == 'A' | |
| ||cadena.charAt(i) == 'E' | |
| ||cadena.charAt(i) == 'I' | |
| ||cadena.charAt(i) == 'O' | |
| ||cadena.charAt(i) == 'U'){ | |
| contador++; | |
| } | |
| } | |
| return contador; | |
| } | |
| public static void main(String args[]){ | |
| int contador = 0; | |
| System.out.println(Cadena("murcielago", contador)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Ejercicio4 { | |
| public static int suma(int numero) { | |
| int sumatory = 0; | |
| for (int i = 1; i <= numero; i++) { | |
| sumatory += i; | |
| } | |
| return sumatory; | |
| } | |
| public static void main(String[] args) { | |
| System.out.println("a: "+suma(9)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment