Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Troubles with loop

 
Manuel Diaz
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?.

THANKS ALL IN ADVANCE
[ May 14, 2005: Message edited by: Mark Spritzler ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()?

Mark
 
Manuel Diaz
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C is the console. Im programing on the console.

THANKS FOR YOUR HELP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic