Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class main {
  4.  
  5. public static void main(String[] args) {
  6. // TODO Auto-generated method stub
  7. float min = 0, max = 0, nbre = 0, somme = 0, input = 0, moyenne = 0;
  8.  
  9. Scanner scan = new Scanner(System.in);
  10.  
  11. System.out.println("Nouvelle valeur :");
  12. input = scan.nextInt();
  13. max = input;
  14. min = input;
  15. somme += input;
  16.  
  17. while (input != 0) {
  18. System.out.println("Nouvelle valeur :");
  19. input = scan.nextInt();
  20.  
  21. if (input > max) {
  22. max = input;
  23. } else if (input < min && input != 0) {
  24. min = input;
  25. }
  26.  
  27. nbre++;
  28. somme += input;
  29. }
  30. if(nbre == 0) {
  31. System.out.println("Grand fou !");
  32. } else {
  33. moyenne = (somme / nbre);
  34. }
  35.  
  36. System.out.println("Max :" + max);
  37. System.out.println("Min :" + min);
  38. System.out.println("Moyenne :" + moyenne);
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement