Advertisement
hombretao

AdministrarCurso

Jun 22nd, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.43 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package administrarcurso;
  6.  
  7. import java.util.Scanner;
  8.  
  9. /**
  10.  *
  11.  * @author tao
  12.  */
  13. public class AdministrarCurso {
  14.  
  15.     /**
  16.      * @param args the command line arguments
  17.      */
  18.     public static void main(String[] args) {
  19.         // TODO code application logic here
  20.         Scanner leer = new Scanner(System.in);
  21.        
  22.         System.out.println( "Administrar Curso" );
  23.         System.out.println( "=================" );
  24.        
  25.         System.out.println( "> Ingresa el nombre del curso:" );
  26.         String nombreCurso = leer.nextLine();
  27.         System.out.println();
  28.        
  29.         System.out.println( "> Ingresa el código del curso:" );
  30.         int codigoCurso = leer.nextInt();
  31.         System.out.println();
  32.        
  33.         Curso curso = new Curso( codigoCurso, nombreCurso );
  34.        
  35.         int comando = 0;
  36.        
  37.         // Agregar alumnos a la mala.
  38.         for (int i = 0; i < 5; i++) {
  39.             Alumno alumno = new Alumno( 123+i, "Juan"+i, "juan"+i+"@mail.com", "casa "+i, 1234567+i );
  40.            
  41.             for (int j = 0; j < 5; j++) {
  42.                 alumno.agregarNota(j+1, 1+j+i);
  43.             }
  44.        
  45.             if( !curso.agregarAlumno( alumno ) )
  46.             {
  47.                 System.out.println("ERROR");
  48.             }
  49.         }
  50.        
  51.         do
  52.         {
  53.             System.out.println("Menú:");
  54.             System.out.println("-----");
  55.             System.out.println("0. Salir.");
  56.             System.out.println("1. Agregar alumno.");
  57.             System.out.println("2. Ver promedio del curso.");
  58.             System.out.println("3. Ver promedio de un alumno (con su rut).");
  59.             System.out.println("4. Ver mejor alumno.");
  60.             System.out.println("5. Ver peor alumno.");
  61.             System.out.println("6. Ver mejores alumnos.");
  62.             System.out.println();
  63.             System.out.println("> Elige una opción:");
  64.            
  65.             comando = leer.nextInt();
  66.            
  67.             switch( comando )
  68.             {
  69.                 case(0): // 0. salir.
  70.                      System.exit(0); break;
  71.                    
  72.                 case(1): // 1. agregar alumno,
  73.                     System.out.println("> Ingresa el Rut:");
  74.                     int rut = leer.nextInt();
  75.                     leer.nextLine();
  76.                     System.out.println();
  77.                    
  78.                     System.out.println("> Ingresa el nombre:");
  79.                     String nombre = leer.nextLine();
  80.                     System.out.println();
  81.                    
  82.                     System.out.println("> Ingresa el e-mail:");
  83.                     String email = leer.nextLine();
  84.                     System.out.println();
  85.                    
  86.                     System.out.println("> Ingresa su dirección:");
  87.                     String direccion = leer.nextLine();
  88.                     System.out.println();
  89.                    
  90.                     System.out.println("> Ingresa el teléfono:");
  91.                     int telefono = leer.nextInt();
  92.                     leer.nextLine();
  93.                     System.out.println();
  94.                    
  95.                     Alumno alumno = new Alumno( rut, nombre, email, direccion, telefono );
  96.                    
  97.                     System.out.println("> Agregar primera nota:");
  98.                     float nota = leer.nextFloat(); leer.nextLine();
  99.                     alumno.agregarNota( 1, nota );
  100.                     System.out.println();
  101.                    
  102.                     System.out.println("> Agregar segunda nota:");
  103.                     nota = leer.nextFloat(); leer.nextLine();
  104.                     alumno.agregarNota( 2, nota );
  105.                     System.out.println();
  106.                    
  107.                     System.out.println("> Agregar tercaera nota:");
  108.                     nota = leer.nextFloat(); leer.nextLine();
  109.                     alumno.agregarNota( 3, nota );
  110.                     System.out.println();
  111.                    
  112.                     System.out.println("> Agregar cuarta nota:");
  113.                     nota = leer.nextFloat(); leer.nextLine();
  114.                     alumno.agregarNota( 4, nota );
  115.                     System.out.println();
  116.                    
  117.                     System.out.println("> Agregar quinta nota:");
  118.                     nota = leer.nextFloat(); leer.nextLine();
  119.                     alumno.agregarNota( 5, nota );
  120.                     System.out.println();
  121.                    
  122.                     if( curso.agregarAlumno( alumno ) )
  123.                     {
  124.                         System.out.println("Alumno guardado correctamente.");
  125.                     }
  126.                     else
  127.                     {
  128.                         System.out.println("No se puede guardar más alumnos.");
  129.                     }
  130.                     System.out.println();
  131.                     break;
  132.                    
  133.                 case(2): // 2. ver el promedio del curso,  
  134.                     System.out.println( "Promedio del curso: "+curso.promedioCurso() );
  135.                     System.out.println();
  136.                     break;
  137.                    
  138.                 case(3): // 3. ver el promedio de un alumno,
  139.                     System.out.println("> Ingresa el rut del alumno:");
  140.                     int buscarRut = leer.nextInt();
  141.                     curso.verPromedioAlumno( buscarRut ); break;
  142.                    
  143.                 case(4): // 4. ver al mejor alumno,
  144.                     Alumno mejorAlumno = curso.mejorAlumno();
  145.                     System.out.println("Mejor alumno:");
  146.                     System.out.println("-------------");
  147.                     System.out.println( mejorAlumno.toString() );
  148.                     System.out.println();
  149.                     break;
  150.                    
  151.                 case(5): // 5. ver al peor alumno,
  152.                     Alumno peorAlumno = curso.peorAlumno();
  153.                     System.out.println("Peor alumno:");
  154.                     System.out.println("------------");
  155.                     System.out.println( peorAlumno.toString() );
  156.                     System.out.println();
  157.                     break;
  158.                    
  159.                 case(6): // 6. listar a los mejores alumnos
  160.                     curso.mejoresAlumnos(); break;
  161.             }
  162.                  
  163.         }while( comando != 0 );
  164.     }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement