Advertisement
Guest User

FizzBuzz main

a guest
Nov 21st, 2012
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.61 KB | None | 0 0
  1. package com.myimportantcompany.fizzbuzz;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         int limitForFizzBuzzProgram = 100;
  7.         for (int forLoopCounter = 0; forLoopCounter <= limitForFizzBuzzProgram; forLoopCounter = forLoopCounter + 1) {
  8.            
  9.             if(isNumberDivisibleByFiveAndThreeWithoutRemainder(forLoopCounter)) {
  10.                 System.out.println(FizzBuzz.FIZZBUZZ);
  11.             } else if(isNumberDivisibleByFiveWithoutRemainder(forLoopCounter)) {
  12.                 System.out.println(Buzz.BUZZ);
  13.             } else if(isNumberDivisibleByThreeWithoutRemainder(forLoopCounter)) {
  14.                 System.out.println(Fizz.FIZZ);
  15.             } else {
  16.                 System.out.println(forLoopCounter);
  17.             }
  18.         }
  19.     }
  20.  
  21.     public static boolean isNumberDivisibleByThreeWithoutRemainder(int number) {
  22.         if (((number / 3) * 3) == number) {
  23.             return true;
  24.         } else {
  25.             return false;
  26.         }
  27.     }
  28.  
  29.     public static boolean isNumberDivisibleByFiveWithoutRemainder(int number) {
  30.         if (((number / 5) * 5) == number) {
  31.             return true;
  32.         } else {
  33.             return false;
  34.         }
  35.     }
  36.  
  37.     public static boolean isNumberDivisibleByFiveAndThreeWithoutRemainder(
  38.             int number) {
  39.         boolean checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  40.         if (((number / 3) * 3) == number) {
  41.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
  42.         } else {
  43.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  44.         }
  45.  
  46.         if (((number / 5) * 5) == number) {
  47.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
  48.         } else {
  49.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  50.         }
  51.         return checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement