-
Need help whit java
Soo my friend helped me out a bit, but he left me whit this test and i told him i couldnt do it then he told me to go ask someone else for help soo i hope you can help me out whit this:
Soo here it is can you make it:
Consider the series of numbers beginning at start and running up to but not including end, so for example start=1 and end=5 gives the series 1, 2, 3, 4. Return a new String[] array containing the string form of these numbers, except for multiples of 3, use "Fizz" instead of the number, for multiples of 5 use "Buzz", and for multiples of both 3 and 5 use "FizzBuzz". In Java, String.valueOf(xxx) will make the String form of an int or other type. This version is a little more complicated than the usual version since you have to allocate and index into an array instead of just printing, and we vary the start/end instead of just always doing 1..100.
fizzBuzz(1, 6) → {"1", "2", "Fizz", "4", "Buzz"}
fizzBuzz(1, :sick: → {"1", "2", "Fizz", "4", "Buzz", "Fizz", "7"}
fizzBuzz(1, 11) → {"1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz"}
Here is where you code:
public String[] fizzBuzz(int start, int end) {
// your code here
}
-
Re: Need help whit java
Do you have any specific java programming questions?
-
Re: Need help whit java
Math is fun and there are a lot of interesting approaches to handling numbers. But when you are dealing with a select range you can just use a switch statement.
https://docs.oracle.com/javase/tutor...ts/switch.html