aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 29237
    
139

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: 18113
    
  39

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: 10912
    
  12

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
Identify all prime numbers between 100 and 200
Find 127th twin-prime pair?
NEED HELP
How to Generate Unique Random Numbers?
Trying to print first 100 prime numbers using an array