UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 10 de junio de 2015

PROBLEMA 45

45.- DADO UN NÚMERO DETERMINAR CUÁNTOS DÍGITOS TIENE.



/*
 * 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

44.- OBTENER LA CANTIDAD DE LOS PRIMEROS N NUMEROS MULTIPLOS DE 5.



/*
 * 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

43.- DADO UN RANGO DE NUMEROS ENTEROS, OBTENER LA CANTIDAD DE NUMEROS PARES QUE CONTIENE.



/*
 * 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

42.-  DADO UN RANGO DE NUMEROS ENTEROS, OBTENER LA CANTIDAD DE NUMEROS ENTEROS QUE CONTIENE.



/*
 * 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


41.- OBTENER LA SUMA DE LOS PRIMEROS N NUMEROS NATURALES POSITIVOS




/*
 * 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, 27 de mayo de 2015

OBRERO-EMPLEADO





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

public class TIENDA_OBRERO_EMPLEADO {

    
    public static void main(String[] args) throws IOException{
              

  int ti, tr;
         double importe, impuesto, monto, pago;      
  BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Ingresar Trabajador: Obrero(0), Empleado(1) ");
  tr=Integer.parseInt(in.readLine());
System.out.println("Ingresar Tienda: A(0), B(1) ");
    ti=Integer.parseInt(in.readLine());
System.out.println("Ingresar Monto: ");
      monto=(double)Float.parseFloat(in.readLine());
importe=(double)Float.parseFloat(in.readLine());


switch(tr)

{

case 0:
    switch (ti)
       {
        case 0: importe=0.8*monto;
        
        
        break;
        case 1: importe=0.9*monto;
       
     break;   
    }
    break;

    case 1:
    
    switch (ti)
    {
        case 0: importe=0.7*monto;
        
        
        break;
        case 1: importe=0.85*monto;
        
      break;  
    }

    default:
   System.out.println("Error, vuelva a ingresar 0 ó 1: ");
break;
}

impuesto=0.18*importe;
pago=1.18*importe;                 

      
System.out.println("El Importe a pagar es: "+importe); 
System.out.println("El Impuesto a pagar es: "+impuesto); 
System.out.println("El Pago total es: "+pago); 


   
    }
}

DIA DE LA SEMANA




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

 */
public class DiaDeLaSemana {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    int n; String m="";
System.out.println("Ingresar un número del 1 al 7" );
Scanner teclado=new Scanner(System.in);
n=teclado.nextInt();


if(n==1){
m="DOMINGO";
System.out.println("EL DÍA DE LA SEMANA ES: "+m);}

if(n==2){
m="LUNES";
System.out.println("EL DÍA DE LA SEMANA ES: "+m);}

if(n==3){
m="MARTES";
System.out.println("EL DÍA DE LA SEMANA ES: "+m);}

if(n==4){
m="MIERCOLES";
System.out.println("EL DÍA DE LA SEMANA ES: "+m);}

if(n==5){
m="JUEVES";
System.out.println("EL DÍA DE LA SEMANA ES: "+m);}

if(n==6){
m="VIERNES";
System.out.println("EL DÍA DE LA SEMANA ES: "+m);}

if(n==7){
m="SABADO";

System.out.println("EL DÍA DE LA SEMANA ES: "+m);}
if (n<1)
    
{System.out.println("NÚMERO DE SEMANA ES INCORRECTO");}
  
if (n>7)
{System.out.println("NÚMERO DE SEMANA ES INCORRECTO");}

  

    }
}

PRECIO A PAGAR



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

 */
public class PRECIOAPAGAR {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
      
  int cali, produc, precio;
  
   Scanner teclado = new Scanner(System.in);     
 System.out.println("Ingrese Producto: ");
 produc=teclado.nextInt();

 System.out.println("Ingrese Calidad: ");
cali=teclado.nextInt();

 if(produc==1&&cali==1)
 {precio=5000;
 System.out.println("El precio es: " +precio);}
 else

     if(produc==1&&cali==2)
     {precio=4500;
     System.out.println("El precio es: " +precio);}
             
    else
     if(produc==1&&cali==3)
     {precio=4000;
     System.out.println("El precio es: " +precio);}
     
     else
     if(produc==2&&cali==1)
     {precio=4500;
     System.out.println("El precio es: " +precio);}
     
     else
     if(produc==2&&cali==2)
     {precio=4000;
     System.out.println("El precio es: " +precio);}

     else
     if(produc==2&&cali==3)
     {precio=3500;
     System.out.println("El precio es: " +precio);}
     
     else
     if(produc==3&&cali==1)
     {precio=4000;
     System.out.println("El precio es: " +precio);}
     
        else
     if(produc==3&&cali==2)
     {precio=3500;
     System.out.println("El precio es: " +precio);}
     
     else
     if(produc==3&&cali==3)
     {precio=3000;
     System.out.println("El precio es: " +precio);}
         
     else
     {System.out.println("Producto y/o Calidad equivocado...");}    
    
         
   
}
}
    
    

miércoles, 22 de abril de 2015

Problema Resuelto 01




Resultado de imagen para suma

package problema.nº2;
import java.io.*;
/**
 *
 * @author ABEL MONTALVAN
 */
public class ProblemaNº2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
       
        int n1,n2,s;
       
       BufferedReader in =new BufferedReader(new  InputStreamReader(System.in));
       System.out.println("numero 1:");
       n1  = Integer.parseInt(in.readLine());
       System.out.println("numero 2:");
       n2  = Integer.parseInt(in.readLine());
     
       s=n1+n2;
     
       System.out.println("");
       System.out.println("suma: " +s);
         
     
    }
}

Problema Propuesto 18


18.- DADO 02 NÚMEROS ENTEROS A Y B, DETERMINAR CUÁL ES MAYOR CON RESPECTO AL OTRO.

Resultado de imagen para A MAYOR QUE B

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package propuesto018;
import java.util.Scanner;
/**
 *
 * @author abel montalvan
 */
public class PROPUESTO018 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    int a,b;
            String X = "";

            Scanner teclado=new Scanner(System.in);
            System.out.print("1er Número(A):");
            a=teclado.nextInt();
            System.out.print("2do Número(B):");
            b=teclado.nextInt();
            
            if(a>b){
                  X = "A es mayor que B";
            }else{
                  if(b>a){
                     X = "B es Mayor que A";
                  }
            }
            if(a==b){
                  X = "A es igual a B";
                  }
            
            System.out.println("");
            System.out.println("EL RESULTADO ES: " +X);
      }
}

Problema Propuesto 17



17.- DADO UN SALDO ANTERIOR. TIPO DE MOVIMIENTO R(RETIRO) O D(DEPOSITO) Y MONTO DE LA TRANSACCION, OBTENER COMO DATO DE SALIDA EL SALDO ACTUAL.


Resultado de imagen para SALDO

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package propuesto017;
import java.util.Scanner;
/**
 *
 * @author abel montalvan
 */
public class PROPUESTO017 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    int sal_ant, monto, sal_actual=0;
    char tipo_mov;
    
    
            Scanner teclado = new Scanner(System.in);
            System.out.print("Ingresar el Saldo: ");
            sal_ant=teclado.nextInt();
            System.out.print("Ingresar el Tipo de Movimiento: ");
            tipo_mov = teclado.next().charAt(0);
            System.out.print("Ingresar el Monto: ");
            monto=teclado.nextInt();
            
            if(tipo_mov=='R'){
                  sal_actual = sal_ant - monto;
            }
            else
            {
                  if(tipo_mov=='D'){
                   sal_actual = sal_ant + monto;
                  }
            }
            
            System.out.println("");
            System.out.print("El saldo actual es: "+sal_actual);
            System.out.println();       
    }
      }

Problema Propuesto 16



16.- PROMEDIO DE LAS 03 MEJORES NOTAS (APROBADO O DESAPROBADO)

Resultado de imagen para APROBADO

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package propuesto016;
import java.util.Scanner;
/**
 *
 * @author abel montalvan
 */
public class Propuesto016 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       int a,b,c,d,Pr=0;
            String X;
                 
          Scanner teclado=new Scanner(System.in);
         
          System.out.print("NOTA 1:");
          a=teclado.nextInt();
          System.out.print("NOTA 2:");
          b=teclado.nextInt();
          System.out.print("NOTA 3:");
          c=teclado.nextInt();
          System.out.print("NOTA 4:");
          d=teclado.nextInt();
            
            if(a<b &&a<c && a<d){
                  Pr=(b+c+d)/3;
            }else{
                  if (b<a&&b<c && b<d){
                       Pr=(a+c+d)/3;
                  }else{
                       if (c<a&&c<b && c<d){
                             Pr=(a+b+d)/3;
                       }else{
                             Pr=(a+b+c)/3;
                       }
                  }
            }
            if(Pr>=11){
                  X="APROBADO";
            }else{
                  X="DESAPROBADO";
            }
           
            System.out.println("");
            System.out.println("PROMEDIO: "+Pr);
            System.out.println("CONDICIÓN: "+X);
      }
}

Problema Propuesto 15


15.- Dado 03 números, devolver los números ordenados en forma ascendente y descendente.



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package propuesto015;
import java.util.Scanner;
/**
 *
 * @author abel montalvan
 */
public class Propuesto015 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
     int a,b,c,Ma=0,I=0,Me=0;
                       
            Scanner teclado=new Scanner(System.in);
            System.out.print("PRIMER NÚMERO:");
            a=teclado.nextInt();
            System.out.print("SEGUNDO NÚMERO:");
            b=teclado.nextInt();
            System.out.print("TERCER NÚMERO:");
            c=teclado.nextInt();
           
           
            if (a>b && a>c){
                  Ma=a;
            }else{
            if (b>a && b>c){
                  Ma=b;
            }else{
                  Ma=c;
            }
            }
            if(a<b &&a<c){
                  Me=a;
            }else{
            if (b<a&&b<c){
                  Me=b;
            }else{
                  Me=c;
                  }
            }
            I=(a+b+c)-(Ma + Me);
          
            
            System.out.println("");
            System.out.println("ORDEN DESCENDENTE: ");
            System.out.println("MAYOR: "+Ma);
            System.out.println("INTERMEDIO: "+I);
            System.out.println("MENOR: "+Me);
            System.out.println("ORDEN ASCENDENTE: ");
            System.out.println("MENOR: "+Me);
            System.out.println("INTERMEDIO: "+I);
            System.out.println("MAYOR: "+Ma);
      }
}

Problema Propuesto 14



14.- DADO UN NUMERO ENTERO DEVOLVER EL DOBLE DEL NUMERO SI EL NUMERO ES POSITIVO, EL TRIPLE SI ES NEGATIVO Y CERO SI ES NEUTRO.


Resultado de imagen para POSITIVO

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package propuesto014;
import java.util.Scanner;
/**
 *
 * @author abel montalvan
 */
public class Propuesto014 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        int a,b;
           

            Scanner teclado=new Scanner(System.in);
            System.out.print("ESCRIBIR UN NÚMERO:");
            a=teclado.nextInt();
           
            //PROCESO
            if (a>0){
                  b=a*2;
            }else{
            if (a<0){
                  b=a*3;
            }else{
                  b=0;
            }
            }
            System.out.println("");
            System.out.println("EL RESULTADO ES: "+b);
            }
      }