Java Student Grade Management System: Courses, Students and Grades
Java Student Grade Management System
This Java console application lets you manage courses, students and grades through an interactive menu. The corrected code below uses valid for loop syntax and the proper switch structure.
Main Menu
- 1 Cursos
- 2 Estudiantes
- 3 Notas
- 4 Salir
Source Code
import java.io.*;
public class PruebaCasa {
BufferedReader in;
String cur[];
String estu[];
int auxcur,auxestu;
int notas[];
float prome[];
int opcion,opcion1,totalc,totalestu;
public PruebaCasa() throws IOException {
in = new BufferedReader(new InputStreamReader(System.in));
Menu();
}
public static void main(String args[]) throws IOException {
PruebaCasa obj = new PruebaCasa();
}
public void Menu() throws IOException {
do {
System.out.println("1 Cursos");
System.out.println("2 Estudiantes");
System.out.println("3 Notas");
System.out.println("4 Salir");
System.out.println("\nINGRESA LA OPCIÓN");
opcion = Integer.parseInt(in.readLine());
switch (opcion) {
case 1: {
Cursos();
break;
}
case 2: {
estu(cur);
break;
}
case 3: {
Notas(cur, estu);
break;
}
default: {
System.out.println("Error la opción no existe");
}
}
if (opcion == 4) break;
} while (true);
}
public void Cursos() throws IOException {
do {
System.out.println("1 INGRESAR CURSOS");
System.out.println("2 VER CURSOS");
System.out.println("3 REGRESAR");
opcion1 = Integer.parseInt(in.readLine());
switch (opcion1) {
case 1: {
System.out.println("Ingresa el total de cursos");
totalc = Integer.parseInt(in.readLine());
cur = new String[totalc];
for (int i = 0; i < totalc; i++) {
System.out.println("INGRESA EL CURSO");
cur[i] = in.readLine();
}
break;
}
case 2: {
System.out.println("Los cursos que existen son:");
for (int i = 0; i < totalc; i++) {
System.out.println(cur[i]);
}
break;
}
}
if (opcion1 == 3) {
break;
}
} while (true);
}
public void estu(String[] cur) throws IOException {
do {
System.out.println("1 INGRESAR ESTUDIANTES");
System.out.println("2 VER ESTUDIANTES");
System.out.println("3 REGRESAR");
opcion1 = Integer.parseInt(in.readLine());
switch (opcion1) {
case 1: {
System.out.println("Ingresar el total de estudiantes");
totalestu = Integer.parseInt(in.readLine());
auxcur = totalestu * totalc;
estu = new String[auxcur];
auxcur = 0;
for (int i = 0; i < totalc; i++) {
System.out.println("CURSO " + cur[i]);
for (int j = 0; j < totalestu; j++) {
System.out.println("Ingresa el nombre del estudiante");
estu[auxcur] = in.readLine();
auxcur = auxcur + 1;
}
}
break;
}
case 2: {
auxcur = 0;
for (int j = 0; j < totalc; j++) {
System.out.println("Los estudiantes del curso " + cur[j]);
for (int i = 0; i < totalestu; i++) {
System.out.println(estu[auxcur]);
auxcur++;
}
}
break;
}
}
if (opcion1 == 3) break;
} while (true);
}
public void Notas(String[] cur, String[] estu) throws IOException {
do {
System.out.println("1 INGRESAR NOTAS");
System.out.println("2 VER NOTAS");
System.out.println("3 REGRESAR");
opcion1 = Integer.parseInt(in.readLine());
switch (opcion1) {
case 1: {
auxcur = totalestu * totalc * 3;
notas = new int[auxcur];
auxcur = totalestu * totalc;
prome = new float[auxcur];
auxcur = 0;
auxestu = 0;
for (int i = 0; i < totalc; i++) {
System.out.println("CURSO " + cur[i]);
for (int j = 0; j < totalestu; j++) {
System.out.println("NOTAS DEL ESTUDIANTE " + estu[auxcur]);
prome[auxcur] = 0;
for (int w = 0; w < 3; w++) {
System.out.println("INGRESA LA NOTA " + (w + 1));
notas[auxestu] = Integer.parseInt(in.readLine());
prome[auxcur] = prome[auxcur] + notas[auxestu];
auxestu = auxestu + 1;
}
prome[auxcur] = prome[auxcur] / 3;
auxcur = auxcur + 1;
}
}
break;
}
case 2: {
auxcur = 0;
auxestu = 0;
for (int i = 0; i < totalc; i++) {
System.out.println("\nCURSO " + cur[i]);
for (int j = 0; j < totalestu; j++) {
System.out.print("\n" + estu[auxcur]);
for (int w = 0; w < 3; w++) {
System.out.print("\t" + notas[auxestu] + " ");
auxestu = auxestu + 1;
}
System.out.print(prome[auxcur]);
if (prome[auxcur] >= 15) {
System.out.print("\t Aprobado");
} else {
System.out.print("\t Reprobado");
}
auxcur = auxcur + 1;
System.out.println();
}
}
break;
}
}
if (opcion1 == 3) break;
} while (true);
}
}