Advertisement
Guest User

EsercizioHHDmain2.0

a guest
Jan 21st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. import Harddisk;
  2. import java.lang.String;
  3. import java.io.*;
  4.  
  5. public static void main(String[] args)
  6. {
  7.     final int MAX_HD = 5;
  8.     Harddisk hhd[] =new Harddisk [MAX_HD];
  9.    
  10.     int a=0,c;
  11.     float d=0;
  12.  
  13.  
  14.     hhd[0]=new Harddisk("Hp", 50, 320, 50);
  15.     hhd[1]=new Harddisk("Dell", 30, 450, 70);
  16.     hhd[2]=new Harddisk("Gigabyte", 70, 400, 60);
  17.     hhd[3]=new Harddisk("Toshiba", 80, 380, 45);
  18.     hhd[4]=new Harddisk("Kingston", 25, 450, 80);
  19.    
  20. //  for(int b=0;b<MAX_HD;b++)
  21. //  {    
  22. //      hhd[b]= new Harddisk();
  23. //      hhd[b].leggiDati();
  24. //  }
  25.  
  26.  
  27. //max
  28.     for(int b=0; b<MAX_HD;b++)
  29.         if(hhd[a].punteggio()>hhd[b].punteggio())
  30.             a=b;
  31.     System.out.println("\nL'Hard Disk con il punteggio maggiore è il numero "+a+" e le sue specifiche sono le seguenti:\n");
  32.     hhd[a].stampaDati();
  33.  
  34. //min  
  35.     for(int b=0; b<MAX_HD;b++)
  36.         if(hhd[a].punteggio()<hhd[b].punteggio())
  37.             a=b;
  38.     System.out.println("Mentre quello peggiore è il numero "+a+" e le sue specifiche sono le seguenti:");
  39.     hhd[a].stampaDati();
  40.  
  41. //media
  42.     for(c=0;b<MAX_HD;c++)
  43.         d+=hhd[c].punteggio;
  44.  
  45.     System.out.println("\n\nLa media dei punteggi degli hard disks è "+(d/c));
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement