Guest User

Untitled

a guest
Jan 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. package edu.hawaii.ics314;
  2.  
  3. /**
  4. * An application that will print out all of the numbers from 1 to 100, one per
  5. * line, except that when the number is a multiple of 3, "Fizz" is printed, when
  6. * a multiple of 5, "Buzz" is printed, and when a multiple of both 3 and 5,
  7. * "FizzBuzz" is printed.
  8. *
  9. * @author Jayson Gamiao
  10. * @assignment ICS 314 Assignment 4
  11. * @date August 31, 2011
  12. */
  13. public class FizzBuzz {
  14. /**
  15. * @param args
  16. */
  17. public static void main(String[] args) {
  18. // Print out all numbers from 1 to 100.
  19. for (int number = 1; number < 101; number++) {
  20. // Print "FizzBuzz" if number is a multiple of 3 and 5.
  21. if (number % 15 == 0) {
  22. System.out.println("FizzBuzz");
  23. // Print "Fizz" if number is a multiple of "Fizz".
  24. } else if (number % 3 == 0) {
  25. System.out.println("Buzz");
  26. // Print "Buzz" if number is a multiple of "Buzz".
  27. } else if (number % 15 == 0) {
  28. System.out.println("FizzBuzz");
  29. // If none of the above is satisfied, print the value of number.
  30. } else {
  31. System.out.println(number);
  32. }
  33. }
  34. }
  35. }
Add Comment
Please, Sign In to add comment