I was instructed to make a FizzBuzz class that has a fizzBuzz method that takes in two int values as parameters. It is not working properly and I am wondering why?
public class FizzBuzz {
public static void main(String[] args) {
int start = 1;
int end = 10;
String[] answers = new String[end +1];
answers = fizzBuzz(start, end);
for (String answer : answers) {
System.out.println(answer);
}
}
public static String[] fizzBuzz(int start, int end) {
String[] storage = new String[end + 1];
for (int i = 1; i < storage.length; i++) {
for(int j = start; j <= storage.length; j++ ) {
if (j % (3 * 5)== 0) {
storage[i] = "fizzbuzz";
}
if(j % 5 == 0) {
storage[i] = "buzz";
}
if (j % 3 == 0) {
storage[i] = "fizz";
}
else {
storage [i] = "" + i;
}
}
}
return storage;
}
}