Mrgentledolphin

temperature

Mar 8th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package scuola;
  2. import java.util.*;
  3. public class arrray1 {
  4.  
  5.     public static void main(String[] args) {
  6.         int[] temp = new int [10];
  7.         int tempmin=9999, tempmax=-200, tot= 0, media=0;
  8.         Scanner input = new Scanner (System.in);
  9.         for(int i=0; i<10; i++){
  10.             System.out.println("inserire temperatura");
  11.             temp[i]=input.nextInt();
  12.         }
  13.         for(int i=0; i<10; i++){
  14.             tot+=temp[i];
  15.         }
  16.         for(int i=0; i<10; i++){
  17.             if(temp[i]<tempmin)
  18.                 tempmin=temp[i];
  19.             if(temp[i]>tempmax)
  20.                 tempmax=temp[i];
  21.         }
  22.         media=tot/10;
  23.         System.out.println("media: "+media);
  24.         System.out.println("temperatura massima: "+tempmax);
  25.         System.out.println("temperatura minima: "+tempmin);
  26.         for(int i=9; i>=0; i--){
  27.             System.out.print(temp[i]+" ");
  28.         }
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment