Advertisement
Guest User

Wetterstation

a guest
Nov 19th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.05 KB | None | 0 0
  1.  
  2. public class Wetterstation
  3. {
  4.     private int [][] array;
  5.     private String[] tage={"Montag    ","Dienstag  ","Mittwoch  ","Donnerstag","Freitag   ","Samstag   ","Sonntag   "};
  6.     private String[] stunden={"0:00Uhr","1:00Uhr","2:00Uhr","3:00Uhr","4:00Uhr","5:00Uhr","6:00Uhr","7:00Uhr","8:00Uhr","9:00Uhr","10:00Uhr","11:00Uhr","12:00Uhr","13:00Uhr","14:00Uhr","15:00Uhr","16:00Uhr","17:00Uhr","18:00Uhr","19:00Uhr","20:00Uhr","21:00Uhr","22:00Uhr","23:00Uhr","24:00Uhr"};
  7.  
  8.     public Wetterstation()
  9.     {
  10.         array = new int [7][24];
  11.     }
  12.  
  13.     public void wetterMessen()
  14.     {
  15.         for(int i=0;i<7;i++)
  16.         {
  17.             for(int j=0;j<24;j++)
  18.             {
  19.                 int temp =(int) (Math.random()*20);
  20.                 array[i][j]=temp;
  21.             }
  22.         }
  23.     }
  24.  
  25.     public void ausgabe()
  26.     {
  27.         System.out.print("\t"+"\t");
  28.         for(int k=0;k<24;k++)
  29.         {
  30.             System.out.print(k+ " Uhr"+"\t");
  31.         }
  32.         System.out.println();
  33.         for(int i=0;i<7;i++)
  34.         {
  35.             System.out.print(tage[i]+"\t");
  36.             for(int j=0;j<24;j++)
  37.             {
  38.                 System.out.print(array[i][j]+"\t");
  39.             }
  40.             System.out.print("\n");
  41.         }
  42.     }
  43.  
  44.     public void durchschnittTag()
  45.     {
  46.         double temp=0;
  47.         for(int i=0;i<7;i++)
  48.         {
  49.             for(int j=0;j<24;j++)
  50.             {
  51.                 temp=array[i][j]+temp;
  52.             }
  53.             System.out.println("Die Durchschnittstemperatur am "+i+". Tag ist "+temp/24+" Grad !");
  54.             temp=0;
  55.         }
  56.     }
  57.  
  58.     public void durchschnitt8()
  59.     {
  60.         double temp=0;
  61.         for(int i=0;i<7;i++)
  62.         {
  63.             temp=array[i][7]+temp;
  64.             System.out.println("Die Durchschnittstemperatur in der Woche um 8 Uhr ist "+temp/7+" !");
  65.         }
  66.     }
  67.  
  68.     public void durchschnitt12()
  69.     {
  70.         double temp=0;
  71.         for(int i=0;i<7;i++)
  72.         {
  73.             temp=array[i][11]+temp;
  74.             System.out.println("Die Durchschnittstemperatur in der Woche um 12 Uhr ist "+temp/7+" !");
  75.         }
  76.     }
  77.  
  78.     public void durchschnitt18()
  79.     {
  80.         double temp=0;
  81.         for(int i=0;i<7;i++)
  82.         {
  83.             temp=array[i][17]+temp;
  84.             System.out.println("Die Durchschnittstemperatur in der Woche um 18 Uhr ist "+temp/7+" !");
  85.         }
  86.     }
  87.  
  88.     public void max()
  89.     {
  90.         int max=0;
  91.         for (int i = 0; i<7; i++)
  92.         {
  93.             for (int j = i + 1; j <24; j++)
  94.             {
  95.                 if (array[i][j]>=max)
  96.                 {
  97.                     max=array[i][j];
  98.                 }
  99.             }
  100.         }
  101.         System.out.println(max);
  102.     }
  103.  
  104.     public void min()
  105.     {
  106.         int min=20;
  107.         for (int i = 0; i<7; i++)
  108.         {
  109.             for (int j = i + 1; j <24; j++)
  110.             {
  111.                 if (array[i][j]<min)
  112.                 {
  113.                     min=array[i][j];
  114.                 }
  115.             }
  116.         }
  117.         System.out.println(min);
  118.     }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement