Está en la página 1de 4

ESTOS SON ALGUNOS PROGRAMAS DISEADOS EN JAVA SUERTE.-.

PARA DISMINUIR LOS NUMERO DE 100 EN 100 O DEPENDE DE CUANT LO QUIERAS


CICLO FOR
class ciclofor{
public static void main(String[]args){
int ciclo;
for(ciclo=1000;ciclo>=-100;ciclo=ciclo-100){
System.out.print("\n"+ciclo);
}
}
}

CICLO WHILE
DE CIERTO NUMERO HASTA EL MISMO NUMERO PERO EN NEGATIVO
class ciclowhile{
public static void main(String[]args){
int ciclo;
ciclo=1000;
while(ciclo>=-1000)
{
System.out.print("\n"+ciclo);
ciclo=ciclo-100;
}
}
}

CICLO DOWHILE
PARA IR DE UNO EN UNO HASTA EL NUMERO QUE UNO ELIJA
class ciclodowhile{
public static void main(String[]args){
int c;
c=1;
do{
System.out.print("\n"+c);
c++;
}while(c<=10);
}
}

PARA SACAR TU PROMEDIO DE CIERTA CANTIDAD DE NUMERO QUE ELIJAS


import java.util.Scanner;
class dowhilemA{
public static void main(String[]arg){
Scanner pedir=new Scanner(System.in);
int suma=0,n,ma,datoent,c;
System.out.print("\nBienvenido a tu promedio");
do{
}
System.out.print("\ncantidad de numeros a valorar:");
n=pedir.nextInt();
for(c=1;c<=n;c++){
System.out.print("\nvalor "+c+":");
datoent=pedir.nextInt();
suma=suma+datoent;
}
ma=suma/n;
System.out.print("\ntu promedio:\n"+ma);
}
}
PARA FACTORIZAR UN NUMERO CUALQUIERA
import java.util.Scanner;
class factorial{
public static void main(String[]arg){
Scanner g=new Scanner(System.in);
int n,f=1,r=1;
System.out.print("\ndame numero a factorizar:");
n=g.nextInt();
System.out.print("\n"+f);
while(f<n){
f++;
r=r*f;
System.out.print("x"+f);
}
System.out.print("="+r);
}
}

METODO FIBONACCI
import java.util.Scanner;
class fibonacci{
public static void main(String[]args){
Scanner dato=new Scanner (System.in);
int a=0,b=1,f,l;
f=a+b;
System.out.print("\ncual es el limite de la serie fibonacci : ");
l=dato.nextInt();
System.out.print("\n "+a+" "+b);
while(f<l){
System.out.print(" "+f);
a=b;
b=f;
f=a+b;
}
}
}

CICLO FOR CALCULADORA


PARA EL NUMERO QUE ELIJAS
import java.util.Scanner;
class cicloforcalculadora{
public static void main(String[]args){
Scanner g=new Scanner(System.in);
int ciclo,t,r;
System.out.print("\n Que tabla quieres:");
t=g.nextInt();
System.out.print("\n\n Resultado de tabla:\n");
for(ciclo=1;ciclo<=10;ciclo++){
r=t*ciclo;
System.out.print("\n "+t+" X "+ciclo+" = "+r);
}
}
}

Que tabla quieres


import java.util.Scanner;
class ciclofor{
public static void main(String[]args){
Scanner g=new Scanner(System.in);
int ciclo,s,p;
System.out.print("\n bienvenido que tabla quieres:");
s=g.nextInt();
System.out.print("\n Resultado de tabla:\n");
for(ciclo=3;ciclo<=30;ciclo=ciclo+3){
p=s*ciclo;
System.out.print("\n "+s+" X "+ciclo+" = "+p);
}
}
}

Aumento de que tabla quieres


import java.util.Scanner;
class tareaciclowhile{
public static void main(String[]args){
Scanner g=new Scanner(System.in);
int ciclo,t,q;
System.out.print("\n bienvenido que tabla quieres:");
t=g.nextInt();
System.out.print("\n Resultado de tabla:\n");
for(ciclo=10;ciclo<=100;ciclo=ciclo+10){
q=t*ciclo;
System.out.print("\n "+t+" X "+ciclo+" = "+q);
}
}
}

También podría gustarte