# Thread: Display multiples of 7

1. Member
Join Date
Apr 2017
Posts
8
Rep Power
0

## Display multiples of 7

Write a program that displays all the multiples of 7 that occur between 1 and 494 in rows of 7 numbers each.
The output looks like this:-
7 14 21 28 35 42 49
56 63 70 77 84 91 98
105 112 119 126 133 140 147
154 161 168 175 182 189 196
203 210 217 224 231 238 245
252 259 266 273 280 287 294
301 308 315 322 329 336 343
350 357 364 371 378 385 392
399 406 413 420 427 434 441
448 455 462 469 476 483 490

2. Member
Join Date
Apr 2017
Posts
8
Rep Power
0

## Java PROGRAM, how do you display multiples to a pacific number

Write a program that displays all the multiples of 7 that occur between 1 and 494 in rows of 7 numbers each.
The output looks like this:-
7 14 21 28 35 42 49
56 63 70 77 84 91 98
105 112 119 126 133 140 147
154 161 168 175 182 189 196
203 210 217 224 231 238 245
252 259 266 273 280 287 294
301 308 315 322 329 336 343
350 357 364 371 378 385 392
399 406 413 420 427 434 441
448 455 462 469 476 483 490

3. ## re: Display multiples of 7

When you have no idea how to start, it's time to turn off the computer, grab a pen and paper and start doing it by hand, on paper, the old school way.

This exercise actually has two parts:
1) Getting from 0 to 494 in steps of 7
2) Printing them out in rows of 7 numbers

For #1, there are multiple ways of doing this, but think about a loop, starting at 7, and keep multiplying that with 1, then 2, then 3, then 4, until the number you get is larger than 494.
For #2, you can actually use the multiplier from #1. When that reaches a number divisible by 7, it's the end of the row and you should go to the next line. (Hint: Java has an operator to calculate the remainder of a division)

4. Member
Join Date
Apr 2017
Posts
2
Rep Power
0

## Re: Java PROGRAM, how do you display multiples to a pacific number

for i in range(1,494,7):

6. Member
Join Date
Apr 2017
Posts
8
Rep Power
0

## Re: Display multiples of 7

YEAH no worries Norm, it was an error.

7. ## Re: Java PROGRAM, how do you display multiples to a pacific number

Originally Posted by nengkya
for i in range(1,494,7):
Congratulations. You managed to post a piece of Python code on a Java forum. Even though there is a Java statement that does the same, it's extremely confusing for someone who just started Java.

8. ## Re: Display multiples of 7

Originally Posted by raghusomineni
Hi, code is below.
Can a moderator please delete this shitty code and give raghu a nice official warning?

DO. NOT. SPOONFEED. CODE. Why? Cos any random student will learn nothing of the exercise his teacher gave him, he will hand this in as code of his own and he will pass his Computer Science classes not because he's smart, but because you posted random solutions to it. He then ends up working in IT, hopefully becoming YOUR colleague. But he stinks cos all he does is copy/paste from you and/or the first answer on StackOverflow. He will get fired because he can't program for jack shit. He will divorce his wife, not allowed to see his kids, and has to take his scruffy dog to live under the bridge. He will be drinking and doing drugs and dies ill-ridden before he turns 40. All because of you.

Or maybe not. Anyway, let this guy finish his exercise on his own.

Edit: Just for clarity: user raghusomineni posted some code that solved OP's problem. Apparently a moderator has waved the delete-stick and the post is gone. (Without the original post, mine doesn't make much sense :))
Last edited by SurfMan; 04-06-2017 at 09:43 AM.

9. Senior Member
Join Date
Sep 2014
Location
MA, USA
Posts
398
Rep Power
5

## Re: Display multiples of 7

So, if you want a good time with your dog, post a question on java-forums.org hoping that sb will spoon feed you. Makes sense to me.

10. ## Re: Display multiples of 7

Originally Posted by benji2505
So, if you want a good time with your dog, post a question on java-forums.org hoping that sb will spoon feed you. Makes sense to me.
You have been around here long enough to see people try that all the time.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•