Guest User

Untitled

a guest
Feb 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. rt java.io.*;
  2. public class piedrapapeltijera {
  3. public static String leerNombre(){
  4. InputStreamReader isr = new InputStreamReader(System.in);
  5. BufferedReader br = new BufferedReader(isr);
  6. String nombre= null;
  7. try{
  8. nombre=br.readLine();
  9. }catch(IOException ioe){
  10. System.out.println("Error al leer del teclado");
  11. System.exit(-1);
  12. }
  13. return nombre;
  14. }
  15. public static void main(String[]args){
  16. System.out.println("Jugador 1, elige: piedra, papel, tijera");
  17.  
  18. {String eleccion_1=leerNombre();
  19. System.out.println("Jugador 2, elige: piedra, papel, tijera");
  20. String eleccion_2=leerNombre();
  21. if(eleccion_1.equals(eleccion_2));
  22. System.out.println("Empate");
  23. if (eleccion_1.equals("piedra"));
  24. else if (eleccion_2.equals("papel"));
  25. System.out.println("Gana jugador 2" + "eleccion_2" + "vence" + "eleccion_1");
  26.  
  27. { if (eleccion_1.equals("piedra"));
  28. else if (eleccion_2.equals("tijeras"));
  29. System.out.println("Gana jugador 1" + "eleccion_1" + "vence" + "eleccion_2");}
  30. { if (eleccion_1.equals("papel"));
  31. else if (eleccion_2.equals("piedra"));
  32. System.out.println("Gana jugador 1" + "eleccion_1" + "vence" + "eleccion_2");}
  33. { if (eleccion_1.equals("papel"));
  34. else if (eleccion_2.equals("tijeras"));
  35. System.out.println("Gana jugador 2" + "eleccion_2" + "vence" + "eleccion_1");}
  36. { if (eleccion_1.equals("tijeras"));
  37. else if (eleccion_2.equals("papel"));
  38. System.out.println("Gana jugador 1" + "eleccion_1" + "vence" + "eleccion_2");}
  39. {if (eleccion_1.equals("tijeras"));
  40. else if (eleccion_2.equals("piedra"));
  41. System.out.println("Gana jugador 2" + "eleccion_2" + "vence" + "eleccion_1");}
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment