Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package exoboucle;
- /**
- *
- * @author Formation
- */
- public class ExoBoucle {
- /**
- * @param args the command line arguments
- *
- * fizz si /3 buzz /5 et fizzbuzz/3 et 5
- */
- public static void main(String[] args) {
- int i = 1;
- int nombreFizz = 0;
- int nombreBuzz = 0;
- int nombreFizzBuzz = 0;
- while (i <= 100) {
- if (i % 3 == 0 && i % 5 == 0) {
- System.out.println("Fizz Buzz");
- nombreFizzBuzz++;
- } else if (i % 5 == 0) {
- System.out.println("Buzz");
- nombreBuzz++;
- } else if (i % 3 == 0) {
- System.out.println("Fizz");
- nombreFizz++;
- }
- System.out.println(i);
- i++;
- }
- System.out.println("Fizz :" + nombreFizz + "\nBuzz : " + nombreBuzz + " \nFizzBuzz : " + nombreFizzBuzz);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement