Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Wetterstation
- {
- private int [][] array;
- private String[] tage={"Montag ","Dienstag ","Mittwoch ","Donnerstag","Freitag ","Samstag ","Sonntag "};
- 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"};
- public Wetterstation()
- {
- array = new int [7][24];
- }
- public void wetterMessen()
- {
- for(int i=0;i<7;i++)
- {
- for(int j=0;j<24;j++)
- {
- int temp =(int) (Math.random()*20);
- array[i][j]=temp;
- }
- }
- }
- public void ausgabe()
- {
- System.out.print("\t"+"\t");
- for(int k=0;k<24;k++)
- {
- System.out.print(k+ " Uhr"+"\t");
- }
- System.out.println();
- for(int i=0;i<7;i++)
- {
- System.out.print(tage[i]+"\t");
- for(int j=0;j<24;j++)
- {
- System.out.print(array[i][j]+"\t");
- }
- System.out.print("\n");
- }
- }
- public void durchschnittTag()
- {
- double temp=0;
- for(int i=0;i<7;i++)
- {
- for(int j=0;j<24;j++)
- {
- temp=array[i][j]+temp;
- }
- System.out.println("Die Durchschnittstemperatur am "+i+". Tag ist "+temp/24+" Grad !");
- temp=0;
- }
- }
- public void durchschnitt8()
- {
- double temp=0;
- for(int i=0;i<7;i++)
- {
- temp=array[i][7]+temp;
- System.out.println("Die Durchschnittstemperatur in der Woche um 8 Uhr ist "+temp/7+" !");
- }
- }
- public void durchschnitt12()
- {
- double temp=0;
- for(int i=0;i<7;i++)
- {
- temp=array[i][11]+temp;
- System.out.println("Die Durchschnittstemperatur in der Woche um 12 Uhr ist "+temp/7+" !");
- }
- }
- public void durchschnitt18()
- {
- double temp=0;
- for(int i=0;i<7;i++)
- {
- temp=array[i][17]+temp;
- System.out.println("Die Durchschnittstemperatur in der Woche um 18 Uhr ist "+temp/7+" !");
- }
- }
- public void max()
- {
- int max=0;
- for (int i = 0; i<7; i++)
- {
- for (int j = i + 1; j <24; j++)
- {
- if (array[i][j]>=max)
- {
- max=array[i][j];
- }
- }
- }
- System.out.println(max);
- }
- public void min()
- {
- int min=20;
- for (int i = 0; i<7; i++)
- {
- for (int j = i + 1; j <24; j++)
- {
- if (array[i][j]<min)
- {
- min=array[i][j];
- }
- }
- }
- System.out.println(min);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement