Está en la página 1de 4

package whilemientras;

import java.util.Scanner;

public class Whilemientras {

public static void main(String[] args) {

int x;

int n;

x=0;

while (x<=100)

System.out.println("numeros>>"+x);

x=x+1;

}
NUMEROS PARES:

package whilemientras;

public class numerosparesciclosmientras {

public static void main(String[] args) {

int x;

int n;

x=0;

while (x<=100)

System.out.println("numeros>>"+x);

x=x+2;

}
NUMEROS IMPARES:

package whilemientras;

public class imparesciclomientras {

public static void main(String[] args) {

int x;

int n;

x=1;

while (x<=100)

System.out.println("numeros>>"+x);

x=x+2;

}
CANTIDAD QUE QUIERA:

package whilemientras;

import java.util.Scanner;

public class cantidadquequiera {

public static void main(String[] args) {

int x;

int n;

int cq;

int ac;

x=1;

cq=0;

ac=0;

System.out.println("ingrese la cantidad de numeros>>");

Scanner leer=new Scanner(System.in);

cq=leer.nextInt();

while (x<cq)

System.out.println("numeros>>"+x);

n=leer.nextInt();

x=x+1;

ac=ac+n;

System.out.println("el acumulado es"+ac);

También podría gustarte