Please help me, IndexOf problem
Hi, I am having big problems using IndexOf. I am trying to create a table of numbers from 1-100 and every time a 5 appears change the word to fiz.
I can do this using multiples of 5 but not when a 5 appears, for example 51 needs to be changed to "fiz"
any help would be greatfully appreciated.
class cw1d
{
public static void main (String[] args)
{
System.out.println("|-----------------------------------------------");
System.out.println("| FizBuz Simulator");
System.out.println("| by ");
System.out.println("|-----------------------------------------------");
int counter;
String number="0";
for (counter=1; counter<=100; counter++)
{
if (counter%5==0 && counter%7==0)
{
System.out.print("fizbuz\t");
}
number=number.indexOf(counter);
// if (counter%5==0)
// {
// System.out.println("fiz");
// }
// else
if (number.indexOf=="5" || counter%5==0)
{
System.out.print("fiz\t");
}
else
{
System.out.println(counter);
}
if (counter%7==0)
{
System.out.print("buz\t");
}
else
{
System.out.print(counter);
System.out.print("\t");
}
}
}
}