jueves, 27 de febrero de 2020

3

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package programa.pkg2;
import java.util.Scanner;
/**
*
* @author Delgado Gustavo
*/
public class Programa2 {

   /**
    * @param args the command line arguments
    */
   public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       System.out.println("Captura el nombre: ");
        String f=sc.next();
       System.out.println("Captura el apellido paterno: ");
        String j=sc.next();
        System.out.println("Captura el apellido materno: ");
        String n=sc.next();
       System.out.println("Captura la edad: ");
        byte k=sc.nextByte();
       System.out.println("Captura el genero: ");
        String p=sc.next();
       System.out.println("Sus datos son : ");
       
       System.out.println(j+ " "+n+" "+f );
       
       if(k>=18){
         System.out.println("sr o Sra");  
       }
       if(k>=13 && k<=17){
         System.out.println("Joven o Srita");  
       }
      if(k<=12){
         System.out.println("niño o niña ");  
       }
       
      int año=2020-k;
      System.out.println("usted nacio en el año:  "+año);  
     
       // TODO code application logic here
   }
   
}

2

 /*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package manejo.de.cadenas;

/**
 *
 * @author Delgado Gustavo
 */
public class ManejoDeCadenas {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
        String nom;//Objeto tipo cadena
        char extraido;//Variable tipo char
        int longuitud;//Variable tipo entero
        nom="Esto es una cadena de texto";//Inicianilazando el objeto nom
       System.out.println(nom);//Imprecion de el objeto
       longuitud=nom.length();//Asignacion de la longuitud de nom
       System.out.println("La longuitud de la cadena es "+longuitud);//Imprecio de la variable longuitud
       extraido=nom.charAt(13);//Extrae caracter numero 13
       System.out.println("El carcter extraido de la cadena es;"+extraido);//Imprecion de a variable extraido
       char [] destino = new char[20];//Crear un vector de caracteres llamado destino
       try{
           nom.getChars(12, 18, destino,0);//Extrae caracteres de 12 a 18 y los en el vector destino
           System.out.println(destino);//Imprime el vector destino
       }
       catch (Exception ex){//atrapa el error de las lineas de try
     
           System.out.println(ex);
        // TODO code application logic here
    }
 
    }

}

1


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tiposdedatos;
import java.util.Scanner;
/**
 *
 * @author Delgado Gustavo
 */
public class TiposDeDatos {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       System.out.println("Delgado Diaz de Leon Gustavo");
       
       System.out.println("valor en variable tipo entero");
       int x=sc.nextInt();
       System.out.println("ciclo FOR");
       for(int j=1;j<=5;j++) {
           System.out.println(x);
       }
           
       System.out.println("valor en variable tipo short");
       short y=sc.nextShort();
       System.out.println("ciclo FOR");
       for(int j=1;j<=7;j++)
           {
           System.out.println(y);
       }
           
       System.out.println("valor en variable tipo long");
       long s=sc.nextLong();
        System.out.println("ciclo FOR");
       for(int j=1;j<=10;j++){
           System.out.println(s);
       }
           
       System.out.println("valor en variable tipo byte");
       byte r=sc.nextByte();
        System.out.println("ciclo FOR");
       for(int j=1;j<=5;j++){
           System.out.println(r);
       }
           
       System.out.println("valor en variable tipo cadena");
       String  o=sc.next();
        System.out.println("ciclo FOR");
       for(int j=1;j<=5;j++){
           System.out.println(o);
       }
       
       System.out.println("valor en variable tipo doble");
       double m=sc.nextDouble();
        System.out.println("ciclo FOR");
       for(int j=1;j<=5;j++){
           System.out.println(m);
       }
       System.out.println("valor en variable tipo boolean");
       boolean p=sc.nextBoolean();
       System.out.println("ciclo FOR");
       for(int j=1;j<=5;j++){
           System.out.println(p);
       }
           
        // TODO code application logic here
    }
   
}