Hi guys, this is most definately so easy for the pro's around here, or even the novice. Thing is I just started learning Java at uni and I'm really baffled by this peice of coding. See, I wrote the following.
What its meant to do is the user inputs a number and depending on that number, thats how many lines will appear in the Command box.
See, main problem is I can't get the println coding arranged properly.
Here is the code I wrote...
Code:
import javax.swing.JOptionPane;
public class TimesTable
{
public static void main (String [] args)
{
String numberEntry;
int inputtedNo;
numberEntry = JOptionPane.showInputDialog("What number should the table go up to?");
inputtedNo = Integer.parseInt(numberEntry);
{
System.out.println("number " + '\t' + '\t' + "times 5" + '\t' + '\t' + "cubed");
// for loop
for(int i = 0; i<inputtedNo; i++)
System.out.println(i*5);
}
}
}
I want 3 rows to appear in the Command box like this:
number times 5 cubed
xx xx xx
xx xx xx
xx xx xx
xx xx xx
xx xx xx
xx being the calculation... my problem is that I can't make it so the calculation (xx's) appear in the rows like above. I add \t to the code but if I do that, it'll reprint number, times 5, and cubed over and over as well .. hope that makes sense.
Anyway I've waffled on long enough, if anyone is still confused let me know. I'd LOVE some help on this as I've just about given up.
Bookmarks