Advertisement
urksiful

Practice Social Service Izcali 01

Oct 10th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. //Main Class
  2. /*
  3.  * To change this license header, choose License Headers in Project Properties.
  4.  * To change this template file, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7. package practica01;
  8.  
  9. /**
  10.  *
  11.  * @author Hantack
  12.  */
  13. public class TokenTest {
  14.    
  15.    
  16.     public static void main(String[] args) {
  17.        TokenEjempo clase = new TokenEjempo();
  18.        
  19.        clase.start();
  20.        
  21.        clase.show();
  22.        
  23.     }
  24.    
  25.    
  26. }
  27.  
  28. // Secondary Class
  29.  
  30.  
  31. package practica01;
  32.  
  33. import java.util.Scanner;
  34. import java.util.StringTokenizer;
  35.  
  36. /**
  37.  *
  38.  * @author Hantack
  39.  */
  40. public class TokenEjempo {
  41.     Scanner xr = new Scanner(System.in);
  42.     public String cad;
  43.    
  44.     public void start(){
  45.         System.out.println("Ingresa Nombre");
  46.         String nombre = xr.nextLine();
  47.         System.out.println("Ingresa Apellido");
  48.         String apellido = xr.nextLine();
  49.         System.out.println("Ingresa Edad");
  50.         int edad = xr.nextInt();
  51.        
  52.         cad = nombre+"*"+apellido+"*"+edad;
  53.        
  54.         System.out.println("Cadena: "+cad);
  55.    
  56.     }
  57.    
  58.     public void show(){
  59.         StringTokenizer tk = new StringTokenizer(cad, "*");
  60.         System.out.println("============="
  61.                 + "\nNombre: "+tk.nextToken()+""
  62.                 + "\nApellido: "+tk.nextToken()+""
  63.                 + "\nEdad: "+tk.nextToken());
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement