Page 134 - Introduccion a la Programacion
P. 134

134     Introducción a la Programación





                            8.  public class Goles_Anotados {
                            9.
                            10.      public static void main(String[] args) {
                            11.          Scanner entrada = new Scanner(System.in);
                            12.          int goles;
                            13.          String nombre;
                            14.
                            15.          System.out.println(“Ingrese el nombre del jugador: “);
                            16.          nombre = entrada.nextLine();
                            17.          System.out.println(“Ingrese la cantidad de goles
                                 anotados: “);
                            18.          goles = entrada.nextInt();
                            19.
                            20.          System.out.println(“El jugador “ + nombre);
                            21.
                            22.          if (goles <= 6) {
                            23.              System.out.println(“Es GOLEADOR”);
                            24.          } else {
                            25.              System.out.println(“Es NO GOLEADOR”);
                            26.          }
                            27.      }
                            28.  }





                           Resultado Java

                           Goleador



                            1.  run:
                            2.  Ingrese el nombre del jugador:
                            3.  Antonio
                            4.  Ingrese la cantidad de goles anotados:
                            5.  8
                            6.  El jugador Antonio
                            7.  Es GOLEADOR
                            8.  BUILD SUCCESSFUL (total time: 8 seconds)
   129   130   131   132   133   134   135   136   137   138   139