Guest User

Untitled

a guest
Jan 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package edu.hawaii.ICS314;
  2. /**
  3. * Print class - loops from number 1 to 100. If the number is divisible by 3, "Fizz" is printed. If the number
  4. * is divisble by 5, "Buzz" is printed. If the number is divisible by both 3 and 5, "FizzBuzz" is printed.
  5. * Otherwise the number is printed.
  6. *
  7. * @author ButuGruv
  8. *
  9. */
  10. public class Print {
  11. public static void main(String[] args) {
  12. //loop 1 to 100
  13. for(int i=1; i<100; i++) {
  14. //print Fizz if divisible by 3
  15. if(i%3 == 0) System.out.println("Fizz");
  16. //print Buzz if divisible by 5
  17. else if (i%5 == 0) System.out.println("Buzz");
  18. //print FizzBuzz if divisible by both
  19. else if (i%5 == 0 && i%3 == 0) System.out.println("FizzBuzz");
  20. //otherwise print the number
  21. else System.out.println(i);
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment