For this program I started coding it using the For Loop but I am not sure how to show the results under the 4 headers. If somebody can help me I would appreciate it.The output on the screen is suppose to looks like this:
N 10*N 100*N 1000*N
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
[/code]public class Forloop
{
public static void main(String[] args)
{
int N;
for ( N = 1; N <= 5; N++)
{
System.out.println(10 * N);
}
for ( N = 1; N <= 5; N++)
{
System.out.println(100 * N);
}
}
}
Nested means one inside another not one after another:
- public class Table {
-
public static void main (String []args) {
-
int n = 1;
-
System.out.println("N 10*N 100*N 1000*N");
-
for(int j = 1; j <= 5; j++) {
-
for(int i = 1; i <= 1000; i = i * 10) {
-
System.out.print(i*j+" ");
-
}
-
System.out.println();
-
}
-
}
-
}