Está en la página 1de 2

package cec.edu.

presentacion;

import java.util.Scanner;

public class Prueba1 {

public static void main(String[] ARGS)

{
Scanner obtener = new Scanner(System.in);

int cantidadNumeros, total, i, nuevoNumero;


System.out.print("\t\t SUMA DE DOS NUMEROS: ");

System.out.print("\n\nIngrese la cantidad de numeros a sumar:


");

cantidadNumeros = obtener.nextInt();

total = 0;

for (i = 1; i <= cantidadNumeros; i++)

System.out.print("Ingrese el numero (" + i + ") : ");

nuevoNumero = obtener.nextInt();

total = total + nuevoNumero;

System.out.print("La suma total de los numeros es : " + total);

public class Prueba1 {

public static void main(String[] args) {


// Sacando la potencia con while
Scanner sc = new Scanner(System.in);
int base, exponente, potencia;
potencia = 1;
System.out.println("\t\t Potencia de un numero");
System.out.println("\n\n Ingrese base:");
base = sc.nextInt();
System.out.println("\n\nIngrese exponente:");
exponente = sc.nextInt();
//VALOR DEBE SER 0
while (0 < exponente) {
potencia = potencia * base;
exponente--;
// AQUI EL EXPONENTE SE DEBE RESTAR -1 YA QUE SE CONTROLA LA MULTIPLICAION
DEL EXPONENTE
}
System.out.println("La Potencia es: " + potencia);

}
}

package cec.edu.presentacion;

import java.util.Scanner;

public class Prueba1 {

public static void main(String[] args) {


for(int i=1; 1<=1000;i++) {
if (i % 2 == 0)
continue;
if (i %3==0)
continue;
System.out.println("numero:" +i);
if(i>=15)
break;
}

}
}

También podría gustarte