Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Troubles with loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Troubles with loop" Watch "Troubles with loop" New topic

Troubles with loop

Manuel Diaz
Ranch Hand

Joined: Apr 22, 2005
Posts: 79
Hi all, I have this code:

OK, What I mean here is, If the first number is greater than 7, then it has to start again until the user input a value less than 7. And the same for second number. This works fine, but when it finish, the program starts again, I want the program finish if the 1 number is < 7 and 2 number is < 7. I dont want the program keep going again and again. What can I do then?.

[ May 14, 2005: Message edited by: Mark Spritzler ]

Note: I love programming.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Well you "while" will continually run because it will always evaluate to true.

Here's a better way to write your code. There are other ways too.

Although what type of Object is the variable "c" set to, instead of just using System.out.println()?


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Manuel Diaz
Ranch Hand

Joined: Apr 22, 2005
Posts: 79
C is the console. Im programing on the console.

I agree. Here's the link:
subject: Troubles with loop
It's not a secret anymore!