package dan;
public class Estudiante {
String nombre;
int edad;
double notas[];
public Estudiante(String nombre, int edad, double[] notas) {
this.nombre = nombre;
this.edad = edad;
this.notas = notas;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public int getEdad() {
return edad;
}
public void setEdad(int edad) {
this.edad = edad;
}
public double[] getNotas() {
return notas;
}
public void setNotas(double[] notas) {
this.notas = notas;
}
public Estudiante(String nombre, int edad) {
this.nombre = "daniel";
this.edad = 18;
}
public Estudiante() {
this.nombre = "maria";
this.edad = 18;
}
}
package dan;
import java.util.*;
public class RunEstudiante {
public static void main(String[] args) {
Scanner sc= new Scanner( System.in);
Estudiante est = new Estudiante();
System.out.println(est.getNombre()+est.getEdad());
Estudiante est1 = new Estudiante("maria",23);
System.out.println(est1.getNombre()+est1.getEdad());
System.out.println("digite su nombre");
String nom = sc .nextLine();
System.out.println("digite su edad");
int ed = sc .nextInt();
Estudiante est2 = new Estudiante(nom,ed);
double notas []= new double[3];
for (int i = 0; i < notas.length; i++) {
System.out.println("digite nota"+"="+i);
notas[i]=sc.nextDouble();
}
est1.setNotas(notas);
for (int i = 0; i < notas.length; i++) {
System.out.println(est1.getNotas()[i]);
}
System.out.println(est1.getNombre()+est1.getEdad()+est1.getNotas());
}
}
No hay comentarios:
Publicar un comentario