Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do i develop 10*10 table using loops

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
In addition to code tags, please take a look at the naming policy.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.")
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic