File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes while loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

while loop

Jim Harvey

Joined: Jun 08, 2007
Posts: 7
Can someone pls show me or get me started in the right direction for writing a while loop to perforem the following steps:

1. Prompt the user to input two integers: dirstNum and secondNum.
2. Output all results to a file, placing an appropriate lable between each section of output.
3. Output all odd numbers between firstNum and secondNum.
4. Output the sum of all even numbers between firstNum and secondNum.
5. Output the numbers and their square between firstNum and secondNum.
6. Output the sun of the squares of the odd numbers between firstNum and secondnum.

Thank you very much/jrh
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Andris Jekabsons
Ranch Hand

Joined: Jan 20, 2004
Posts: 82
You can divide your assignment in several parts: receiving input from user, writing to a file and performing calculations on numbers. Read more about the first two on Java Tutorial and then you can ask more specific questions.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

This thread is a dup. of this one. Please post any follow ups over there.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: while loop
jQuery in Action, 3rd edition