• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiplication table from a file

 
Matt Deg
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a homework assignment that I am stuck on, we are to create a multiplication table from a file that we are given,

we were given this to start with....I got everything up to where I have to create the nested loop...any help on how to do this would be greatly appreciated




Thanks you

Update: Added Code tags. Please read UseCodeTags
 
Zeeshan Sheikh
Ranch Hand
Posts: 144
Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Logic for Nested Loop

for every value of table '1' run inner loop 10 times and output value to screen.


 
Matt Deg
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the output should be something like this

4 5 6
- - -
1 | 4 5 6
2 | 8 10 12
3 | 12 15 18



3 4 5 6 7 8 9
- - - - - - -
2 | 6 8 10 12 14 16 18
3 | 9 12 15 18 21 24 27
4 | 12 16 20 24 28 32 36
 
Campbell Ritchie
Sheriff
Pie
Posts: 50278
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are trying to do too much at once. I think you ought to get something which prints out the numbers running, then later work out how to format them. A lot pf people try to do everything in one step, and that makes it difficult to do anything.
 
Victor M. Pereira
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where do you store the value your going to multiply?

If you had an array called values

the first for would print i + "| "
then the second for would multiply each value times i and print it
after the for you do a println() for sake of looks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic