Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.61 KB | None | 0 0
  1. /*
  2. 4.      Introduir 10 notes i calcular:
  3. •     Mitja de totes les notes.
  4. •     Mitja de notes aprovades.
  5. •     Mitja de notes suspeses.
  6. •     Nº d' aprovats y suspesos.
  7. Falta   contar los supendidos con nota par
  8. Falta   el alumno con la nota más baja
  9.  */
  10.  
  11. import java.io.*;
  12. class ex4{
  13. public static int getMinValue(int[] array){  
  14.      int minValue = array[0];  
  15.      for(int i=1;i<array.length;i++){  
  16.      if(array[i] < minValue){  
  17.      minValue = array[i];  
  18.         }  
  19.      }  
  20.     return minValue;  
  21. }  
  22.  
  23.         public static void main (String args[]){
  24.                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  25.                 try{
  26.                         boolean rep=true;
  27.                         int i;
  28.                         int op; int aprovats; int suspesos; double medNotes; double medAp;
  29.                         double medSus; double acNotes=0; double acAp=0; double acSus=0; int cAp=0; int cSus=0;
  30.                         double [] v = new double [10];
  31.                         for  (i=0; i<10; i++){
  32.                                 System.out.println ("Nota "+(i+1));
  33.                                 v[i] = Double.parseDouble(br.readLine());
  34.                         acNotes=acNotes+v[i];  
  35.                                    
  36.                         if (v[i]>=5){
  37.                                 cAp++;
  38.                                
  39.                                         acAp=acAp+v[i];
  40.                                
  41.                         }
  42.             double lowest=getMinValue(v);
  43.             ArrayList list = new ArrayList();
  44.             for  (i=0; i<10; i++){
  45.                 if (v[i]%2==0) list.add(v[i]);
  46.             }
  47.                         if (v[i]<5){
  48.                                 cSus++;
  49.                                         acSus=acSus+v[i];
  50.                         }
  51.                        
  52.                         }
  53.                         medNotes=acNotes/10;
  54.                         medAp=acAp/cAp;
  55.                         medSus=acSus/cSus;
  56.                         while (rep=true){
  57.                         do{
  58.                                 System.out.println("[0] - Salir");
  59.                                 System.out.println("[1] - Mitja de totes les notes");
  60.                                 System.out.println("[2] - Mitja notes aprovades");
  61.                                 System.out.println("[3] - Mitjana  de suspesos");
  62.                                 System.out.println("[4] - Numero d'aprovats i suspesos");
  63.                                 System.out.println("Opcion: ");
  64.                                 op=Integer.parseInt(br.readLine());
  65.                         }while ((op<0) || (op>4));
  66.  
  67.                         switch (op){
  68.                         case 1:
  69.                                 System.out.println("Mitja de totes les notes es: "+medNotes);
  70.                                
  71.                                 break;
  72.                         case 2:
  73.                                 System.out.println("Mitja de notes aprovades es: "+medAp);
  74.                                 break;
  75.                         case 3:
  76.                                 System.out.println("Mitja de notes suspeses es: "+medSus);
  77.                                 break;
  78.                         case 4:
  79.                                 System.out.println("Numero de aprovados: "+cAp);
  80.                                 System.out.println("Numero de suspesos: "+cSus);
  81.                                 break;
  82.                         }
  83.                 }
  84.                 }
  85.                 catch(Exception e){
  86.                         System.out.println(e);
  87.                 }
  88.         }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement