Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class G3E3
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner sc = new Scanner(System.in);
  8.  
  9. double x, y, media, max = -Double.MAX_VALUE, min = Double.MAX_VALUE, sum=0;
  10. int c=0;
  11.  
  12.  
  13. System.out.print("Insira o seu conjunto de números: ");
  14. x = sc.nextInt();
  15. c++;
  16.  
  17. do
  18. {
  19. System.out.print("Insira o seu conjunto de números: ");
  20. y = sc.nextInt();
  21. if(x==y)
  22. break;
  23. c++;
  24. if(y>max)
  25. max=y;
  26. if(y<min)
  27. min=y;
  28. sum+=y;
  29. }while(true);
  30.  
  31. media = sum/c;
  32.  
  33. System.out.printf("O valor máximo é %f, o valor mínimo é %f, a média é %f e foram inseridos %d números.", max, min, media, c);
  34.  
  35. sc.close();
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement