I am having problems with a java program using classes. The problem is that when I run the program name, age and career are requested when I enter the name all right, when I enter the age and give it to enter to run only run the println but do not wait for the data to enter but which jumps to the next parameter.
I do not understand why he jumps and does not wait for him to give him the information.
My code is as follows:
package compararedades;
import java.util.Scanner;
/**
*
* @author ERICK UNITEC
*/
public class CompararEdades {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
nombre a1 = new nombre();
edad e0 = new edad();
carrera c1 = new carrera();
System.out.println("Bienvenido");
System.out.println("Ingrese el nombre del primer alumno");
String n1 = sc.nextLine();
a1.nombre1(n1);
System.out.println("Ingrese la edad del primer alumno");
int edad1 = sc.nextInt();
e0.ed1(edad1);
System.out.println("Ingrese la carrera");
String carr1 = sc.nextLine();
c1.establecercarrera1(carr1);
System.out.println("Ingrese el nombre del segundo alumno");
String n2 = sc.next();
a1.nombre2(n2);
System.out.println("Ingrese la edad del segundo alumno");
int edad2 = sc.nextInt();
e0.ed2(edad2);
System.out.println("Ingrese la carrera");
String carr2 = sc.nextLine();
c1.establecercarrera2(carr2);
if(e0.Obteneredad1()> e0.Obteneredad2()){
System.out.printf("La edad de %s es mayor que la de %s",a1.obtenernombre1(),a1.obtenernombre2());
}
else{
System.out.printf("La edad de %s es mayor que la de %s",a1.obtenernombre2(),a1.obtenernombre1());
}
}
}