Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package promedio;
- /**
- *
- * @author BLACKANGEL
- */
- public class Promedio {
- private String[] tareasLloyd={"90","97","75","92"}, pruebasLloyd={"88","40","94"},examenesLloyd={"75","90"};
- private String[] tareasAlice={"100","92","98","100"}, pruebasAlice={"82","83","91"},examenesAlice={"89","97"};
- private String[] tareasTyler={"0","87","7522"}, pruebasTyler={"0","75","78"}, examenesTyler={"100","100"};
- private String[][] Lloyd={{"Lloyd"}, tareasLloyd,pruebasLloyd,examenesLloyd};
- private String[][] Alice={{"Alice"},tareasAlice,pruebasAlice,examenesAlice};
- private String[][] Tylor={{"Tylor"}, tareasTyler,pruebasTyler,examenesTyler};
- private String[][][] estudiantes={Lloyd, Alice, Tylor};
- private void print(){
- for(int i=0; i<estudiantes.length; i++){
- System.out.println(estudiantes[i][0][0]+":");
- for(int j=1; j<estudiantes[i].length; j++){
- System.out.print("[");
- for(int k=0; k<estudiantes[i][j].length; k++){
- if(k==estudiantes[i][j].length-1)
- System.out.print(estudiantes[i][j][k]);
- else
- System.out.print(estudiantes[i][j][k]+", ");
- }
- System.out.print("]");
- System.out.println();
- }
- }
- }
- private static String promedio(String[] lista){
- double suma=0;
- int cont=0;
- double promedio=0;
- for(int i=0; i<lista.length; i++){
- suma+=Double.parseDouble(lista[i]);
- cont++;
- }
- promedio=suma/cont;
- return String.valueOf(promedio);
- }
- private String calcularPromedio(String[][] lista){
- double prom=0;
- for(int i=1; i<lista.length; i++){
- switch(i){
- case(1):
- prom=Double.parseDouble(promedio(lista[i]))*0.1;
- continue;
- case(2):
- prom+=Double.parseDouble(promedio(lista[i]))*0.3;
- continue;
- case(3):
- prom+=Double.parseDouble(promedio(lista[i]))*0.6;
- break;
- }
- }
- return String.valueOf(prom);
- }
- private String obtenerCalificaionenLetras(double nota){
- nota=Math.round(nota);
- if(nota>=90)
- return "A";
- if(nota>=80 & nota<90)
- return "B";
- if(nota>=70 & nota <80)
- return "C";
- if(nota>=60 & nota <70)
- return "D";
- if(nota<60)
- return "F";
- return " ";
- }
- private String calcularPromedioClase(String [][][] lista) {
- double promedio=0;
- int cont=0;
- double prom=0;
- for(int i=0; i<lista.length; i++){
- promedio+=Double.parseDouble(calcularPromedio(lista[i]));
- cont++;
- }
- prom=promedio/cont;
- return String.valueOf(prom);
- }
- public static void main(String[] args) {
- Promedio p1=new Promedio();
- System.out.println(p1.calcularPromedioClase(p1.estudiantes));
- System.out.println(p1.obtenerCalificaionenLetras(Double.parseDouble(p1.calcularPromedioClase(p1.estudiantes))));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement