jueves, 7 de mayo de 2015

FIBONACCI USANDO "FOR" Y CON "N" DE NUMERO CON DOS CLASES!!

FIBONACCI USANDO "FOR" Y CON "N" DE NUMERO


PRIMERA CLASE!!

public class PRACTICA14_1
{
// SE REALIZAN LAS OPERACIONES!!

public static void CalcularSerie()
{
        Scanner leer = new Scanner(System.in);
        int a, b, cantidad, c;
        System.out.println("Cantidad de numeros");
        cantidad = leer.nextInt();
        a=1;
        b=0;
        for (int i = 0; i < cantidad; i++)
        {
       
           
            c =a+b;
            System.out.println(c);
            a=b;
            b=c;
           
    }
       
       
       
       
}
   
}

SEGUNDA CLASE!!


public class PRACTICA14_2
{
   
public static void main(String[] args)
{
     //Nombre de la clase
    PRACTICA14_1 obj = new PRACTICA14_1 ();
    //Nombre del void
    obj.CalcularSerie();
    //fin
    obj = null;
   
}
   
}

Ejemplo:
Cantidad de numeros
6
1
1
2
3
5
8

PIRÁMIDE DE REDUCCIÓN USANDO " FOR " Y " N " COMO NUMERO CON DOS CLASES!!

PIRÁMIDE DE REDUCCIÓN USANDO " FOR " Y " N " COMO NUMERO
" EXAMEN "

PRIMER CLASE!!

public class Matematicas
{

    public static void CalcularSerie()
    {
        Scanner leer=new Scanner(System.in);
        System.out.println("DAME EL TAMAÑO DE LA SERIE!!  ");
        int num=leer.nextInt();
         int aux=num;
   
        for (int fila = 1; fila <= num; fila++)
        {

            for (int i =1 ; i<=aux; i++)
            {
                System.out.print(aux);
           
           
            }
            aux--;
            System.out.println(" ");
        }
     
     
    }
 
}

SEGUNDA CLASE!!

public class Examen40
{
    public static void main(String[] args)
    {
        Matematicas obj = new Matematicas();
        obj.CalcularSerie();

    }
 
}


Ejemplo:

DAME EL TAMAÑO DE LA SERIE!!
6
666666
55555
4444
333
22
1