Win a copy of Functional Reactive Programming this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic

How do i develop 10*10 table using loops

 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 618
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 710
  • Mark post as helpful
  • send pies
  • Report post to moderator
In addition to code tags, please take a look at the naming policy.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.")
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
    Bookmark Topic Watch Topic
  • New Topic