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 generating numbers from 1 to 100 to store in an array 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
Bookmark "generating numbers from 1 to 100 to store in an array" Watch "generating numbers from 1 to 100 to store in an array" New topic
Author

generating numbers from 1 to 100 to store in an array

Muzafar Ali
Ranch Hand

Joined: Jun 11, 2009
Posts: 34
write a program to generate 100 int numbers, strore in array, then display all those numbers which are prime numbers?

but how i can print prime numbers from 1 to 100 but this whole question confused me?


~When You Learn Anything, Learn by Heart !
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Muzafar Ali wrote:write a program to generate 100 int numbers, strore in array, then display all those numbers which are prime numbers?

but how i can print prime numbers from 1 to 100 but this whole question confused me?


Think of it as three steps.
1) Can you write a loop that iterates 100 times?
2) Can you create an array of those numbers?

So far, this should be easy.

Now the prime number part. How do you know if a number is prime? Try talking it out by writing here and then once you have the idea you can write it as code.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Muzafar Ali
Ranch Hand

Joined: Jun 11, 2009
Posts: 34
Thanks for your reply sir,
A prime number is a number which is self devisble, mean a number that cannot be devide with other numbers!
am i correct sir?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18538
    
  40

Muzafar Ali wrote:A prime number is a number which is self devisble, mean a number that cannot be devide with other numbers! am i correct sir?


Correct. Now how do you propose testing to see if a number is prime?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Muzafar Ali
Ranch Hand

Joined: Jun 11, 2009
Posts: 34
Thanks,

In program i can but when combining whole the program i can't !
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Where are you having problems?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

how would you test a number like 81 to see if it was prime? Forget about java, write it out in words. How would you start?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://www.wolframalpha.com/input/?i=PrimeQ[81]

So we use HTTPClient to create a request...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generating numbers from 1 to 100 to store in an array
 
Similar Threads
Trying to print first 100 prime numbers using an array
Identify all prime numbers between 100 and 200
How to Generate Unique Random Numbers?
NEED HELP
Find 127th twin-prime pair?