Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. package util;
  2.  
  3. import java.util.*;
  4.  
  5. public class Start
  6. {
  7. public static void main(String[] args)
  8. {
  9. Scanner scan = new Scanner(System.in);
  10. System.out.println("Combien de chiffre voulez-vous encoder ?");
  11. int nbChiffre = scan.nextInt();
  12.  
  13. Integer[] tab = new Integer[nbChiffre];
  14. for (int i = 0; i < nbChiffre; i++)
  15. {
  16. System.out.println(String.format("Entrez le chiffre N° %d / %d", i+1, nbChiffre));
  17. tab[i] = scan.nextInt();
  18. }
  19.  
  20.  
  21. while (true)
  22. {
  23. System.out.println("0: quitter");
  24. System.out.println("1: moyenne");
  25.  
  26. int choice = scan.nextInt();
  27. if (choice == 0)
  28. {
  29. System.out.println("hé chékébam");
  30. break;
  31. }
  32.  
  33. // Moyenne
  34. if (choice == 1)
  35. {
  36. double mean = 0;
  37. for (int i = 0; i < nbChiffre; i++)
  38. mean += tab[i];
  39.  
  40. mean /= nbChiffre;
  41.  
  42. System.out.println("Moyenne : " + mean);
  43. continue;
  44. }
  45.  
  46. if (choice == 2)
  47. {
  48.  
  49. continue;
  50. }
  51.  
  52. }
  53.  
  54. scan.close();
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement