This is a simple variation on the well known http://codingdojo.org/kata/FizzBuzz/ kata exercise.
Feel free to change whatever you want of the existing boilerplate code, it's there just to save you set up time.
It's a maven based project, so it should be easy to import it in your favourite IDE. There are some Junit 5 test cases. They can be executed from the IDE or from the command line by running:
mvn test
We use LTS Java version 17 and Java 17 is the baseline here. Feel free to use any Java version (17 or above) which works for you. You can change the java version in the pom.xml file by editing following line:
<java.version>17</java.version>
There are 2 tasks. They depend on each other so start with Task 1 then continue with Task 2.
Write code in FizzBuzz that produces the following output for each number in a contiguous range of integers:
- the number itself
fizz
for numbers that are multiples of 3buzz
for numbers that are multiples of 5fizzbuzz
for numbers that are multiples of 15
Being careful to avoid trailing spaces.
E.g. running the program with a range from 1-20
should produce the following result:
1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz 16 17 fizz 19 buzz
Please enhance your existing FizzBuzz (you can use for that AlfrescoFizzBuzz) solution to perform the following:
If the number contains a three you must output the text alfresco
, any other rule is skipped.
E.g. running the program with a range from 1-20
should produce the following result:
1 2 alfresco 4 buzz fizz 7 8 fizz buzz 11 fizz alfresco 14 fizzbuzz 16 17 fizz 19 buzz