En la parte del segundo ELSE en el CASE 1 me aparece el error "else without if" .
import java.util.Scanner;
public class PruebaAdmonPersonal {
public static void main(String args[]) {
Scanner leer = new Scanner(System.in);
int opc, id, horasContrato, celda, dato, resp;
String nombre, fechaNac, puesto;
char sexo;
AdmonPersonal ap = new AdmonPersonal();
Personal p;
do{
System.out.println("\nCATALGO DE MA");
System.out.println("[1] ALTAS");
System.out.println("[2] CONSULTA INDIVIDUAL");
System.out.println("[3] CONSULTA GENERAL");
System.out.println("[4] MODIFICACIONES");
System.out.println("[5] BAJAS");
System.out.println("[6] FINALIZAR");
System.out.println("¿Opcion deseada? [1-6]: ");
opc = leer.nextInt();
switch(opc) {
case 1: //ALTAS
if(ap.hayEspacio()) {
System.out.print("ingrese el id del maestro a dar de alta");
id= leer.nextInt();
if(ap.validarId(id)) {
} else {
System.out.println("El id no es valido, ingrese uno del en el rango 1-100... presione ENTER para continuar");
leer.nextLine(); leer.nextLine();
} else {//aqui aparece el error without if
System.out.println("Base de datos llena,presione ENTER para continuar");
leer.nextLine(); leer.nextLine();
}
}
break;
case 2: //CONSULTA INDIVIDUAL
break;
case 3: //CONSULTA GENERAL
break;
case 4: //MODIFICACIONES
break;
case 5: //BAJAS
break;
case 6: //FINALIZAR
System.out.println("\nProgramador: " +"Julio Adriel Velázquez Ponce");
System.out.println("14-octubre-2021");
System.out.println("Gracias por utilizar el CATALOGO DE MAESTROS");
break;
default:
System.out.println("Opcion no valida...Presiona ENTER para continuar");
leer.nextLine(); leer.nextLine(); //Pausa
}
} while(opc != 6);
}
}
if
antes del últimoelse
. Lo estás colocando justo después, cuando tiene que ir antes.