Advertisement
Guest User

Ejercicio 8

a guest
Sep 16th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     void procesar()
  2.     {
  3.     Alumno a=new Alumno("Juan",13,15);
  4.     listado(a);
  5.     a.setNota1(19);
  6.     a.setNota2(18);
  7.     listado(a);
  8.        
  9.     void listado(alumno x)
  10.     {
  11.     imprimir("Nombre: "+x.getNombre());
  12.     imprimir("Nota 1: "+x.getNota1());
  13.     imprimir("Nota 2: "+x.getNota2());
  14.     imprimir("Promedio: "+x.promedio());
  15.     }
  16.  
  17.     nombre : Juan
  18.     nota 1: 13
  19.     nota 2: 15
  20.     promedio : 14.0
  21.  
  22.     nombre : Juan
  23.     nota 1: 19
  24.     nota 2: 18
  25.     promedio : 18.5
  26.  
  27.         public int getNota1()
  28.         {  
  29.         return nota1;
  30.         }
  31.  
  32.         public int getNota2()
  33.         {  
  34.         return nota2;
  35.         }
  36.  
  37.     //Metodos de acceso: set
  38.  
  39.         public void setNombre(String nom)  
  40.         {
  41.         nombre=nom;
  42.         }
  43.  
  44.         public void setNota1(int n)    
  45.         {
  46.         nota1=n;
  47.         }
  48.  
  49.         public void setNota2(int n)    
  50.         {
  51.         nota2=n;
  52.         }
  53.  
  54.     //Operaciones
  55.         public double promedio()
  56.         {
  57.         return (nota1+nota2)/2.0;
  58.         }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement