Hi People,
This is my question:
Write an application to:
Print the 5 times table (5 * 1 = 5, 5* 2 =10, .. 5 * 12 = 60)
Format of output
5 * 1 = 5
5 * 2 = 10
etc.
Hint: Write the Java code to print the line for the 4th row, use a variable row of
type int to hold the value 3 Then using the value held in row print the
4th line.
4 * 3 = 20
Enclose
And this is my code:
public void multTable(int n)
{
int m = i* n;
String line=" ";
if(i<=10)
{
line+=" "+i;
}else{
line+=i;
}
line +=" * " + n + "=";
if(m<100)
{
line+=" ";
}
line +=m;
System.out.println(line);
}
}
But the problem is, I want it to become as 5*1 = 5 etc BUT its coming up as 0*1=0 etc... always starts with 0? how do I put a 5 instead of a 0???
Thanks!! R x hope u can help!