• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java guessing game

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone i made  a java guessing game where the where the user is asked to guess a secret number into an input box.

When the user enters the number there are 3 possibilitys which can be seen below in the code. How do i get the program to keep running until the correct answer is guessed while helping the user by stating it's to high or to low. And I have to use a sentinel controlled loop(while loop).

Here's the code:

 
Greenhorn
Posts: 4
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean something like this?

 
Geralt Rivea
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cor Zwart wrote:Do you mean something like this?



Basically when user inputs a number less  then 23 it goes to the second loop and when the user inputs again
This time a number greater than 23 its unable to go back to the first loop because it's already past.
 
Cor Zwart
Greenhorn
Posts: 4
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hint:

 
Geralt Rivea
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cor Zwart wrote:Hint:



Thanks so much for your help its much appreciated!
 
Marshal
Posts: 79036
375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cor Zwart, welcome to the Ranch
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic