Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rt java.io.*;
- public class piedrapapeltijera {
- public static String leerNombre(){
- InputStreamReader isr = new InputStreamReader(System.in);
- BufferedReader br = new BufferedReader(isr);
- String nombre= null;
- try{
- nombre=br.readLine();
- }catch(IOException ioe){
- System.out.println("Error al leer del teclado");
- System.exit(-1);
- }
- return nombre;
- }
- public static void main(String[]args){
- System.out.println("Jugador 1, elige: piedra, papel, tijera");
- {String eleccion_1=leerNombre();
- System.out.println("Jugador 2, elige: piedra, papel, tijera");
- String eleccion_2=leerNombre();
- if(eleccion_1.equals(eleccion_2));
- System.out.println("Empate");
- if (eleccion_1.equals("piedra"));
- else if (eleccion_2.equals("papel"));
- System.out.println("Gana jugador 2" + "eleccion_2" + "vence" + "eleccion_1");
- { if (eleccion_1.equals("piedra"));
- else if (eleccion_2.equals("tijeras"));
- System.out.println("Gana jugador 1" + "eleccion_1" + "vence" + "eleccion_2");}
- { if (eleccion_1.equals("papel"));
- else if (eleccion_2.equals("piedra"));
- System.out.println("Gana jugador 1" + "eleccion_1" + "vence" + "eleccion_2");}
- { if (eleccion_1.equals("papel"));
- else if (eleccion_2.equals("tijeras"));
- System.out.println("Gana jugador 2" + "eleccion_2" + "vence" + "eleccion_1");}
- { if (eleccion_1.equals("tijeras"));
- else if (eleccion_2.equals("papel"));
- System.out.println("Gana jugador 1" + "eleccion_1" + "vence" + "eleccion_2");}
- {if (eleccion_1.equals("tijeras"));
- else if (eleccion_2.equals("piedra"));
- System.out.println("Gana jugador 2" + "eleccion_2" + "vence" + "eleccion_1");}
- }
- }
- }
Add Comment
Please, Sign In to add comment