ProModel interview question
Write a numeric array where any number devisable by three returns "Pro", divisible by 5 returns "Model", and divisible by three and five returns "ProModel"
Interview Answers
I was so flustered (IT's A DATA JOB, NOT A JAVASCRIPT JOB) that I did a pretty poor job in answering.
This is a variation on the fizzbuzz question.
public class Test
{
public static void main(String[] args)
{
String buzz = "buzz", fizz = "fizz"; //initialise the string variables
for (int i = 1; i <= 100; i++)
{
if (i % 15 == 0) //check if number in position i is divisable by 15, if so don't check other 2 conditions - we don't want a double print
{
System.out.println(buzz + fizz + " " + i));
}
else if (i % 3 == 0 )
{
System.out.println(buzz + " " + i);
}
else if (i % 5== 0)
{
System.out.println(fizz + " "+ i);
}
}
}
}