miércoles, 10 de junio de 2015

PROBLEMA 45



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema45dadounnumerodeterminarcuantosdigitostiene;
import java.util.Scanner;
/**
 *

 */
public class Problema45dadounnumerodeterminarcuantosdigitostiene {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       int n,c=0;
       Scanner teclado=new Scanner(System.in);
       System.out.println("Número: " );
       n=teclado.nextInt();
       
       while (n>0)
       {
       n=n/10;
       c+=1;
       }
       System.out.println(" " );
       System.out.println("Cantidad de Dígitos: "+c);

    }
}

PROBLEMA 44



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema44cantidaddeprimerosnnumerosmultiplosde5;
import java.util.Scanner;
/**
 *

 */
public class Problema44cantidaddeprimerosnnumerosmultiplosde5 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
     int i, n,c=0;
       Scanner teclado=new Scanner(System.in);
       System.out.println("Número: " );
       n=teclado.nextInt();
       i=1;
       while (i<=n)
       {
       if  (i%5==0)
       {    
       c+=1;
       }
       i++;
       
       }       
       System.out.println(" " );
       System.out.println("Cantidad: "+c);

    }
}

PROBLEMA 43



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema43dadounrangodenumerosenterosobtenerlacantidaddenumerospares;
import java.util.Scanner;
/**
 *

 */
public class PROBLEMA43DADOUNRANGODENUMEROSENTEROSOBTENERLACANTIDADDENUMEROSPARES {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
     int i, ni,nf,cp=0;
       Scanner teclado=new Scanner(System.in);
       System.out.println("Número Inicial: " );
       ni=teclado.nextInt();
       System.out.println("Número Final: " );
       nf=teclado.nextInt();
       i=ni+1;
       while (i<nf)
       {
       if  (i%2==0)
       {    
       cp+=1;
       }
       i++;
       
       }       
       System.out.println(" " );
       System.out.println("Cantidad Pares: "+cp);

    }
}

PROBLEMA 42



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema42dadounrangodenumerosenterosobtenerlacantidaddenumerosenterosquecontiene;
import java.util.Scanner;
/**
 *

 */
public class PROBLEMA42DADOUNRANGODENUMEROSENTEROSOBTENERLACANTIDADDENUMEROSENTEROSQUECONTIENE {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
     int i, ni,nf,c=0;
       Scanner teclado=new Scanner(System.in);
       System.out.println("Número Inicial: " );
       ni=teclado.nextInt();
       System.out.println("Número Final: " );
       nf=teclado.nextInt();
       i=ni+1;
       while (i<nf)
       {
       c+=1;
       i++;
       
       }       
       System.out.println(" " );
       System.out.println("Cantidad: "+c);

    }
}

PROBLEMA 41



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema41.suma.de.primeros.numeros.naturales.positivos;
import java.util.Scanner;
/**
 *

 */
public class PROBLEMA41SUMADEPRIMEROSNUMEROSNATURALESPOSITIVOS {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       int i, n, s=0;
      
       System.out.println("Número: " );
       Scanner teclado=new Scanner(System.in);
       n=teclado.nextInt();
       i=1;
       while (i<=n)
       {
       s=s+i;
       i=i+1;
       
       }       
       System.out.println(" " );
       System.out.println("Suma: "+s);

    }
}

miércoles, 22 de abril de 2015

propu_1



package propuesto1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PROPUESTO1 {

    public static void main(String[] args) throws IOException {
     
        int a,b,s,r;
        BufferedReader in=new BufferedReader(new  InputStreamReader(System.in));
 System.out.println("a: ");
 a=Integer.parseInt(in.readLine());//ojo
  System.out.println("b: ");
 b=Integer.parseInt(in.readLine());//ojo
 s=a+b;
 System.out.println("");
 System.out.println("suma:" + s);
 System.out.println();
 r=a-b;
  System.out.println("");
 System.out.println("Resta:" + r);
 System.out.println();
    }
}

propu_2




package propuesta2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PROPUESTA2 {

    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        int  a=150 , b=-78 ;
        int totalenteros;
               BufferedReader in=new BufferedReader(new  InputStreamReader(System.in));
 System.out.println("ingresar a: ");
 a=(int)Integer.parseInt(in.readLine());//ojo
  System.out.println("ingresar b: ");
  b=(int)Integer.parseInt(in.readLine());//ojo
  
 totalenteros=a-b-1;
 
 System.out.println("");
  System.out.println("el total de enteros entre"+a+"y "+b+" es:"+totalenteros);
 System.out.println();
    
    }
}