java
Publicado por jonathan (4 intervenciones) el 29/03/2019 15:07:48
necesito realizar este programa ayuda .


Valora esta pregunta


-2
public class Persona {
private String nombre;
/**
* @return the nombre
*/
public String getNombre() {
return nombre;
}
/**
* @param nombre the nombre to set
*/
public void setNombre(String nombre) {
this.nombre = nombre;
}
}
public class Materia {
private String nombre;
private Double nota;
public Materia(String nombre) {
this.nombre = nombre;
nota = 0.0;
}
/**
* @return the nombre
*/
public String getNombre() {
return nombre;
}
/**
* @param nombre the nombre to set
*/
public void setNombre(String nombre) {
this.nombre = nombre;
}
/**
* @return the nota
*/
public Double getNota() {
return nota;
}
/**
* @param nota the nota to set
*/
public void setNota(Double nota) {
this.nota = nota;
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class Estudiante extends Persona {
private String nivel;
private String aprovado;
private List<Materia> materias;
public Estudiante() {
materias = new ArrayList();
materias.add(new Materia("Física"));
materias.add(new Materia("Lógica"));
materias.add(new Materia("Matemática"));
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
List<Estudiante> estudiantes = new ArrayList();
boolean agregarEstudiante;
do {
Estudiante e = new Estudiante();
System.out.print("Introduzca el nombre: ");
e.setNombre(br.readLine());
System.out.print("Introduzca el nivel: ");
e.setNivel(br.readLine());
for (Materia m : e.getMaterias()) {
System.out.print("Introduzca la nota de la materia " + m.getNombre() + ": ");
m.setNota(Double.parseDouble(br.readLine()));
}
estudiantes.add(e);
System.out.print("Introduzca 1 para agregar otro estudiante: ");
agregarEstudiante = br.readLine().equals("1");
} while (agregarEstudiante);
estudiantes.forEach(e -> {
System.out.println("Nombre: " + e.getNombre());
System.out.println("Nivel: " + e.getNivel());
System.out.println("Matricula: " + e.getAprovado());
System.out.println("Materias:");
e.getMaterias().forEach(m -> {
System.out.println("\t" + m.getNombre() + ": " + m.getNota());
});
System.out.println("------------------------------------------------");
});
}
/**
* @return the nivel
*/
public String getNivel() {
return nivel;
}
/**
* @param nivel the nivel to set
*/
public void setNivel(String nivel) {
this.nivel = nivel;
}
/**
* @return the aprovado
*/
public String getAprovado() {
aprovado = "SI";
for (Materia m : materias) {
if (m.getNota() < 7.0) {
aprovado = "NO";
break;
}
}
return aprovado;
}
/**
* @param aprovado the aprovado to set
*/
public void setAprovado(String aprovado) {
this.aprovado = aprovado;
}
/**
* @return the materias
*/
public List<Materia> getMaterias() {
return materias;
}
/**
* @param materias the materias to set
*/
public void setMaterias(List<Materia> materias) {
this.materias = materias;
}
}