Advertisement
Hello-Sweety

Untitled

Jan 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package exoboucle;
  7.  
  8. /**
  9. *
  10. * @author Formation
  11. */
  12. public class ExoBoucle {
  13.  
  14. /**
  15. * @param args the command line arguments
  16. *
  17. * fizz si /3 buzz /5 et fizzbuzz/3 et 5
  18. */
  19. public static void main(String[] args) {
  20. int i = 1;
  21. int nombreFizz = 0;
  22. int nombreBuzz = 0;
  23. int nombreFizzBuzz = 0;
  24. while (i <= 100) {
  25.  
  26. if (i % 3 == 0 && i % 5 == 0) {
  27.  
  28. System.out.println("Fizz Buzz");
  29. nombreFizzBuzz++;
  30.  
  31. } else if (i % 5 == 0) {
  32.  
  33. System.out.println("Buzz");
  34. nombreBuzz++;
  35.  
  36. } else if (i % 3 == 0) {
  37.  
  38. System.out.println("Fizz");
  39.  
  40. nombreFizz++;
  41.  
  42. }
  43.  
  44. System.out.println(i);
  45.  
  46. i++;
  47. }
  48.  
  49. System.out.println("Fizz :" + nombreFizz + "\nBuzz : " + nombreBuzz + " \nFizzBuzz : " + nombreFizzBuzz);
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement