Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.myimportantcompany.fizzbuzz;
- public class Main {
- public static void main(String[] args) {
- int limitForFizzBuzzProgram = 100;
- for (int forLoopCounter = 0; forLoopCounter <= limitForFizzBuzzProgram; forLoopCounter = forLoopCounter + 1) {
- if(isNumberDivisibleByFiveAndThreeWithoutRemainder(forLoopCounter)) {
- System.out.println(FizzBuzz.FIZZBUZZ);
- } else if(isNumberDivisibleByFiveWithoutRemainder(forLoopCounter)) {
- System.out.println(Buzz.BUZZ);
- } else if(isNumberDivisibleByThreeWithoutRemainder(forLoopCounter)) {
- System.out.println(Fizz.FIZZ);
- } else {
- System.out.println(forLoopCounter);
- }
- }
- }
- public static boolean isNumberDivisibleByThreeWithoutRemainder(int number) {
- if (((number / 3) * 3) == number) {
- return true;
- } else {
- return false;
- }
- }
- public static boolean isNumberDivisibleByFiveWithoutRemainder(int number) {
- if (((number / 5) * 5) == number) {
- return true;
- } else {
- return false;
- }
- }
- public static boolean isNumberDivisibleByFiveAndThreeWithoutRemainder(
- int number) {
- boolean checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
- if (((number / 3) * 3) == number) {
- checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
- } else {
- checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
- }
- if (((number / 5) * 5) == number) {
- checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
- } else {
- checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
- }
- return checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement