elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Mensajes
Páginas: [1]
1  Programación / Java / Ayuda Programa de planilla alumnos en: 23 Octubre 2012, 04:52 am
Se me pide hacer una planilla tabulada con el ingreso de los alumnos y sus notas, de ahí imprimir todo tabulado cada alumno y sus notas mas su promedio y un promedio general del curso, con los nombre no hay problema de impresión, pero con el arreglo de las notas no guarda todas, solo las del ultimo alumno, ademas adjunto una imagen de como era realmente pedido el problema. Ojala puedan ayudarme, este es mi primera duda y estoy ingresando recién en el foro,



Código
  1. public class Alumno {
  2.  
  3. String Nombre;
  4. String Rut;
  5.  
  6. public void Display(){
  7.  
  8. System.out.println("NOMBRE"+"\t RUT"+"\t N1"+"\t N2"+"\t PROMEDIO");
  9. System.out.println("______________________________________________________________________________________\n");
  10.  
  11. }
  12.  
  13. }
  14.  
Código
  1. import java.util.Scanner;
  2. public class Cabecera {
  3.  
  4. private static Scanner reader,reader1,reader2;
  5.  
  6. public static void main(String[] args) {
  7.  
  8. Alumno alumno = new Alumno();
  9. Planilla planilla = new Planilla();
  10.  
  11.  
  12. System.out.println("INGRESO DATOS DE LA CLASE ");
  13. System.out.println();
  14.  
  15. System.out.println("\nIngrese Periodo :");
  16.        reader= new Scanner(System.in);
  17.        String periodo =reader.next();
  18.        planilla.setPeriodo(periodo);
  19.  
  20.        System.out.println("Ingrese Asignatura:");
  21.        reader1= new Scanner(System.in);
  22.        String asignatura =reader1.next();
  23.        planilla.setAsignatura(asignatura);
  24.  
  25.        System.out.println("Ingrese Profesor:");
  26.        reader2= new Scanner(System.in);
  27.        String profesor = reader2.next();
  28.        planilla.setProfesor(profesor);
  29.  
  30.  
  31.        planilla.alumnoIn();
  32.        System.out.println();
  33.  
  34.  
  35.  
  36.        planilla.Display();
  37.        alumno.Display();
  38.        planilla.alumnoOut();
  39.        planilla.promGral();
  40.  
  41.  
  42. }
  43. }
Código
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Planilla {
  5.  
  6.  
  7. String Periodo;
  8. String Asignatura;
  9. String Profesor;
  10. float SumaNotas=0;
  11.  
  12.  
  13. String alumno [] = new String [1];
  14. String rut[] = new String[1];
  15. Alumno alumnos = new Alumno();
  16. float nota []  = new float [2];
  17.  
  18. Scanner nombre=new Scanner(System.in);
  19. Scanner id=new Scanner(System.in);
  20. Scanner leer=new Scanner(System.in);
  21.  
  22. public void setPeriodo(String periodo){
  23. this.Periodo = periodo;
  24. }
  25. public String getPeriodo(){
  26. return this.Periodo;
  27. }
  28. public void setAsignatura(String asignatura){
  29. this.Asignatura = asignatura;
  30. }
  31. public String getAsignatura(){
  32. return this.Asignatura;
  33. }
  34. public void setProfesor(String profesor){
  35. this.Profesor = profesor;
  36. }
  37. public String getProfesor(){
  38. return this.Profesor;
  39. }
  40.  
  41.  
  42. public void alumnoIn(){
  43.  
  44. for(int i = 0; i < alumno.length ;i++ ){
  45. System.out.println("\nIngrese Nombre del Alumno "+(i+1)+":");
  46. alumno[i] = nombre.next();
  47. System.out.print("Ingrese Rut Alumno Numero "+(i+1)+":");
  48.         rut[i]=id.next();
  49.         notasIn();
  50. }
  51. }
  52.  
  53.  
  54. public void notasIn(){
  55.   for (int n=0;n<nota.length;n++){
  56.    System.out.print("Ingrese Nota "+(n+1)+":");
  57.    nota[n]=leer.nextFloat();
  58.   SumaNotas=SumaNotas+nota[n];
  59.   }
  60.  
  61. }
  62.  
  63.  
  64. public void alumnoOut(){
  65.  
  66. for(int i = 0; i < alumno.length ; i++){
  67. System.out.print(alumno[i]+"\t "+rut[i]);
  68. notaOut();
  69. }
  70. }
  71. public void notaOut(){
  72.   for (int n=0;n<nota.length;n++){
  73.         System.out.print("\t"+nota[n]);
  74.   }
  75.   System.out.println();
  76.   }
  77.  
  78.  
  79. public Planilla(){
  80. }
  81. public Planilla(String periodo, String asignatura, String profesor){
  82. Periodo=periodo;
  83. Asignatura=asignatura;
  84. Profesor=profesor;
  85. }
  86.  
  87. public void Display(){
  88. System.out.println("\n______________________________________________________________________________________");
  89. System.out.println("PLANILLA");
  90. System.out.println("______________________________________________________________________________________\n");
  91. System.out.print("Periodo :"+" "+ Periodo+"\t\t  Asignatura :"+" "+ Asignatura+"\t  Profesor :"+" "+ Profesor);
  92. System.out.println("\n______________________________________________________________________________________\n");
  93.  
  94. }
  95.  
  96. public void promGral(){
  97. System.out.println("______________________________________________________________________________________\n");
  98. System.out.println("\t                                                           PROMEDIO GENERAL:");
  99. System.out.println("______________________________________________________________________________________\n");
  100.   }
  101. }
  102.  
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines