Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class FINAL {
- //Crear la matriz de calificaciones de 20x10
- public static String[][] matrizNotas = new String[20][10];
- public static Scanner sc = new Scanner(System.in);
- public static int alumnoCalif = 0;
- public static void main(String[] args) {
- int opcion = 0;
- while(opcion != 7){
- System.out.println("**********************\n"
- + "1. Ingresar datos del alumno\n"
- + "2. Ingresar calificación\n"
- + "4. Reportes por actividad\n"
- + "6. Imprimir matriz de notas\n"
- + "7. Salir\n"
- + "**********************");
- opcion = sc.nextInt();
- switch(opcion){
- case 1: ingresarAlumno();
- break;
- case 2: califs();
- break;
- case 4: reportesPorActividad();
- break;
- case 6: imprimirMatriz();
- break;
- }
- }
- }
- public static void imprimirMatriz(){
- for (int i = 0; i < matrizNotas.length; i++) {
- System.out.println(Arrays.toString(matrizNotas[i]));
- }
- }
- public static void ingresarAlumno(){
- System.out.println("Selecciona el número de alumno a ingresar (1-20) puedes escribir 0 si no sabes en cuál vas.");
- int alumno = sc.nextInt();
- //Pedir el nombre:
- System.out.println("Ingresa el nombre del alumno:");
- String nombre = sc.next();
- if(alumno != 0){
- matrizNotas[alumno-1][0] = nombre;
- }
- else{
- int indice = -1;
- for (int i = 0; i < matrizNotas.length; i++) {
- if(matrizNotas[i][0] == null){
- indice = i;
- break;
- }
- }
- if(indice != -1){
- matrizNotas[indice][0] = nombre;
- }
- else{
- System.out.println("Matriz llena");
- }
- }
- }
- public static void califs(){
- System.out.println("Selecciona el número de alumno a ingresar (1-20) puedes escribir 0 si no sabes en cuál vas.");
- alumnoCalif = sc.nextInt();
- int opciones = 0;
- while(opciones != 9){
- System.out.println("**********************\n"
- + "1. Ingresar nota tarea 1\n"
- + "2. Ingresar nota tarea 2\n"
- + "3. Ingresar nota tarea 3\n"
- + "4. Ingresar nota tarea 4\n"
- + "5. Ingresar nota examen parcial 1\n"
- + "6. Ingresar nota examen parcial 2\n"
- + "6. Ingresar nota proyecto final"
- + "7. Ingresar nota examen final\n"
- + "9. Salir"
- + "**********************");
- opciones = sc.nextInt();
- switch(opciones){
- case 1: tarea1();
- break;
- case 2: tarea2();
- break;
- /*case 3: tarea3();
- break;
- case 4: tarea4();
- break;
- case 5: actividad1();
- break;
- case 6: actividad2();
- break;
- case 7: proyeFin();
- break;
- case 8: exFinal();
- break;
- case 9: salir();
- break;*/
- }
- }
- }
- public static void tarea1(){
- System.out.println("Selecciona el número de alumno a ingresar (1-20) puedes escribir 0 si no sabes en cuál vas.");
- int alumno = sc.nextInt();
- //Pedir el nombre:
- System.out.println("Ingresa la tarea 1 del alumno:");
- String calif1 = sc.next();
- if(alumno != 1){
- matrizNotas[alumno-1][1] = calif1;
- }
- else{
- int indice = -1;
- for (int i = 0; i < matrizNotas.length; i++) {
- if(matrizNotas[i][1] == null){
- indice = i;
- break;
- }
- }
- if(indice != -1){
- matrizNotas[indice][1] = calif1;
- }
- else{
- System.out.println("Matriz llena");
- }
- }
- }
- public static void tarea2(){
- System.out.println("Selecciona el número de alumno a ingresar (1-20) puedes escribir 0 si no sabes en cuál vas.");
- int alumno = sc.nextInt();
- //Pedir el nombre:
- /*System.out.println("Ingresa la tarea 1 del alumno:");
- String calif1 = sc.next();
- if(alumno != 1){
- matrizNotas[alumno-1][1] = calif1;
- }
- else{
- int indice = -1;
- for (int i = 0; i < matrizNotas.length; i++) {
- if(matrizNotas[i][1] == null){
- indice = i;
- break;
- }
- }
- if(indice != -1){
- matrizNotas[indice][1] = calif1;
- }
- else{
- System.out.println("Matriz llena");
- }
- }*/
- System.out.println("Ingresa la tarea 2 del alumno:");
- String calif2 = sc.next();
- if(alumno != 1){
- matrizNotas[alumno-1][2] = calif2;
- }
- else{
- int indice = -1;
- for (int i = 0; i < matrizNotas.length; i++) {
- if(matrizNotas[i][2] == null){
- indice = i;
- break;
- }
- }
- if(indice != -1){
- matrizNotas[indice][2] = calif2;
- }
- else{
- System.out.println("Matriz llena");
- }
- }
- }
- public static void reportesPorActividad(){
- System.out.println("Ingresa el número de actividad 1-9");
- int ac = sc.nextInt();
- System.out.println("Selecciona una opción\n"+
- "1. Promedio\n"+
- "2. Varianza\n"+
- "3. DevEst\n");
- int act = sc.nextInt();
- if(act == 1){
- double promedio = obtenerPromedio(ac);
- System.out.println("El promedio es: " + promedio);
- }
- else if(act == 2){
- double tot = 0;
- int cuantos = 0;
- double prom = obtenerPromedio(ac);
- for (int i = 0; i < matrizNotas.length; i++) {
- if(matrizNotas[i][ac]!=null){
- tot += Math.pow(Double.parseDouble(matrizNotas[i][ac])-prom,2);
- cuantos++;
- }
- }
- double varianza = tot/cuantos;
- System.out.println("La varianza es: " + varianza);
- }
- else{
- double tot = 0;
- int cuantos = 0;
- double prom = obtenerPromedio(ac);
- for (int i = 0; i < matrizNotas.length; i++) {
- if(matrizNotas[i][ac]!=null){
- tot += Math.pow(Double.parseDouble(matrizNotas[i][ac])-prom,2);
- cuantos++;
- }
- }
- double varianza = tot/cuantos;
- varianza = Math.sqrt(varianza);
- System.out.println("La DevEst es: " + varianza);
- }
- }
- public static double obtenerPromedio(int col){
- //Calcular e imprimir promedio de esa col...
- double tot = 0;
- int cuantos = 0;
- for (int i = 0; i < matrizNotas.length; i++) {
- if(matrizNotas[i][col]!=null){
- tot += Double.parseDouble(matrizNotas[i][col]);
- cuantos++;
- }
- }
- double prom = tot/cuantos;
- return prom;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement