473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Help on looping in java

Let me first start off by saying I am a beginner at Java. I need help on an assignment to produce a loop which I believe for this particular assignment would be the for loop. The output needs to look 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

To get this result would I need nested loops also. I appreciate any help on this problem. Thank you.
Oct 29 '06 #1
3 2213
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);
}
}
}
Oct 30 '06 #2
r035198x
13,262 8TB
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:

Expand|Select|Wrap|Line Numbers
  1. public class Table {
  2.     public static void main (String []args) {
  3.         int n = 1;
  4.         System.out.println("N  10*N   100*N  1000*N");
  5.         for(int j = 1; j <= 5; j++) {
  6.             for(int i = 1; i <= 1000; i = i * 10) {
  7.                 System.out.print(i*j+"    ");
  8.             }
  9.             System.out.println();
  10.         }
  11.     }
  12. }
Oct 30 '06 #3
Ok thanks for your help. :)
Oct 30 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Comcast News | last post by:
Hi , We are facing a java issue. We are looping thru a resultset which has about 40 K records. The process terminates abnormally after about 20-25K records. The Query fetches has 400 columns. We...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
4
by: Tigger2000 | last post by:
I keep getting an error when trying to compile this for Java prog class, below is the instructions for the assignment and my code. Loop Assignment Write, compile, and run a Java program that...
12
by: steven acer | last post by:
hello, i have a java app that constructs an xml from a specific file format and vice versa. i've been asked to convert it to c++, but im not an expert in c++, actually im mere beginner you can...
5
by: sandyw | last post by:
I need help in two areas: Both are at the bottom of my program where a client has two choice to make, 1. When the client enter "Y" it takes him to the begin of the program. I would like to know...
24
by: tanmay | last post by:
please tell me how to get the following output using loops... 1) * * * * * * * * * * * * * * * *
1
by: twin2003 | last post by:
need help with inventory part 5 here is what I have to do Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next...
15
by: colemanj4 | last post by:
Here is what I have so far, it loops while the PW is incorrect, or until cancel is selected. I want it to lock the tables for adds, deletes, and edits when cancel is selected, and if the PW is...
5
by: Ayebaleet | last post by:
Hello everybody, I understand the basics of Java, but not such features as are helpful in an applet namely Listeners. I wanted to create a feature like this: A program would be displayed in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.