Enter names in java [duplicate]

2

I'm doing a program that captures names and grades, you can enter how many grades you want but you should not have scored more than 10. However my program is not letting you enter the name of the student. What is the error?

import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;

public class Calificaciones{
   public static void main (String[]args){
      Scanner entrada;
      entrada=new Scanner(System.in);
      Scanner entrada2;
      entrada2=new Scanner(System.in);

      String nombre;
      int opcion_menu=0; int ejecutar=0; int calificacion; 
      int x=0; 
      int promedio;  
      int otro=0;

      do{
         System.out.println("Eliga la opcion deseada \n 1.Captura \n 2.Consulta \n 3.Salida ");
         opcion_menu=entrada.nextInt();
         if(opcion_menu==1)
         {
            System.out.println("Ingresa el nombre del alumno");
            nombre=entrada.nextLine();
           do{
            System.out.println("Ingresa la calificacion:");
            calificacion=entrada.nextInt();
            System.out.println("Otro? \n 1.Si .No");
            otro=entrada.nextInt();
            }while(otro !=2);

         }
      }while (ejecutar !=0);

   }
}
    
asked by Stephanie B Bautista 09.02.2017 в 15:38
source

1 answer

1

The condition of the first do-while is the one that only lets you enter once, ejecutar is always zero and you're wondering while it's different from zero is still running, you could change within the while that ejecutar == 0 and put a condition that if opcion_menu == 3 change ejecutar = 1 for example.

    
answered by 09.02.2017 в 16:25