This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How do i develop 10*10 table using loops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

How do i develop 10*10 table using loops

Dmitri Makovetskiy
Ranch Hand

Joined: Jun 21, 2010
Posts: 128
i want to use loops (while)

i think i am half way there. but i cant make a code..

class Ex5
{
public static void main(String[] args)
{
int count;
count=0;
while(count<10)
{
System.out.println(count+1);
count=count+1;

}



int count1;
count1=0;
while(count<10)
{
System.out.println(count1+1);
count1=count1+1;

}



}




}


the table should be 10 by 10. a row and a column, it should be a multiplier table

help
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Thank you for posting your code but please use code tags when posting code in the future. Yes you need two loops but one needs to be nested within the other. The outer loop is responsible for your rows. The inner loop is responsible for your columns (Ten columns for each row - 10 * 10 - for 100 pieces of data). If I read your code right, you have two loops, one after the other in your code. This will give you 10 + 10 or 20 pieces of data.

To use the code tag, highlight the code that you post and then click the Code button, which is above the edit box. The Code button will add the appropriate markup to the text. so that it displays very nicely with line numbers.
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
In addition to code tags, please take a look at the naming policy.


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Rather than using "count" and "count1," more descriptive names might help you with the logic. For example, "RowNum" and "ColumnNum."

(Also, your second while condition should use "count1" instead of "count.")


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
His post appears to have been "solved" in a cross-post: link to java-forums post

OP, please read the FAQ before posting including BeForthrightWhenCrossPostingToOtherSites
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How do i develop 10*10 table using loops
 
Similar Threads
strange checkbox problem
Implementing auto increment programitcally
i cant crack this code
help me in improving performance of prepared statement
Problems searching through a list