Problem: Feed Nibble Monster Till Full Write a program that generates a number in [0, 500] at the beginning -- this corresponds to how hungry the monster is -- and keeps asking the user to feed the monster until that number falls to zero. Each time the user feeds the monster a nibble, hunger decreases by the decimal value of the character (i.e. if the user feeds 'A' hunger decreases by 65). But when the user feeds the monster some character that isn't a nibble, the hunger increases by the decimal value of the character (since puking depletes energy). Use while loop. Sample runs: Notice the loop exits after one iteration, because hunger was very low and one nibble made the monster full: wer on DESKTOP ZIONDUL MINGWOT / C/ COUT SES/CSZU11/ Code $ java NibbleMonsterwithLoopTill Full Monster hungry :E HUNGER: 2 Feed monster nibble :o a yum! Monster full :). You may go. weron@DESKTOP-2T8KDUL MINGW64 /c/courses/cs2011/code Notice hunger increasing after non-nibble (pink highlight): Weron DESKTOP 21IONDOL MINOWOT / C/ COUT SES/CSZUII/ CODE INOWOT $ java NibbleMonsterwith LoopTill Full Monster hungry :E HUNGER: 384 Feed monster nibble :o b yum! HUNGER: 286 Feed monster nibble :0 EWANI
Problem: Feed Nibble Monster Till Full
Write a program that generates a number in [0, 500] at the beginning -- this corresponds to how hungry the monster is -- and keeps asking the user to feed the monster until that number falls to zero.
Each time the user feeds the monster a nibble, hunger decreases by the decimal value of the character (i.e. if the user feeds 'A' hunger decreases by 65). But when the user feeds the monster some character that isn't a nibble, the hunger increases by the decimal value of the character (since puking depletes energy).
Use while loop.
Sample runs:
Notice the loop exits after one iteration, because hunger was very low and one nibble made the monster full:
Notice hunger increasing after non-nibble (pink highlight):
Notice that the program just keeps going when the user feeds the monster only non-nibbles. Do you think the program will keep running forever if the user never gives the monster nibbles?
![**Problem: Feed Nibble Monster Till Full**
Write a program that generates a number in [0, 500] at the beginning -- this corresponds to how hungry the monster is -- and keeps asking the user to feed the monster until that number falls to zero.
Each time the user feeds the monster a nibble, hunger decreases by the decimal value of the character (i.e., if the user feeds 'A', hunger decreases by 65). But when the user feeds the monster some character that isn't a nibble, the hunger increases by the decimal value of the character (since puking depletes energy).
Use a while loop.
**Sample runs:**
Notice the loop exits after one iteration, because hunger was very low and one nibble made the monster full:
```
$ java NibbleMonsterWithLoopTillFull
Monster hungry : E
H U N G E R: 2
Feed monster nibble : o
yum!
Monster full :).
You may go.
```
Notice hunger increasing after non-nibble (pink highlight):
```
$ java NibbleMonsterWithLoopTillFull
Monster hungry : E
H U N G E R: 384
Feed monster nibble : o
yum!
H U N G E R: 273
Feed monster nibble : z
Eww! o-O
H U N G E R: 395
Feed monster nibble : f
yum!
H U N G E R: 293
Feed monster nibble : o
yum!
H U N G E R: 192
Feed monster nibble : o
yum!
H U N G E R: 136
Feed monster nibble : o
yum!
H U N G E R: 70
Feed monster nibble : o
yum!
Monster full :).
You may go.
```
Notice that the program just keeps going when the user feeds the monster only non-nibbles. Do you think the program will keep running forever if the user never gives the monster nibbles?
```
$ java NibbleMonsterWithLoopTillFull
Monster hungry : E
H U N G E R: 89
Feed monster nibble : o
Eww! o-O
H U N G E R: 131
Feed monster nibble : o
Eww! o-O
H U N G E R: 169
Feed monster nibble : o
E](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7c961e2d-9b44-43f0-83eb-aafe7530a8fa%2F874fc0e4-0168-419c-9414-b8cea7d596bf%2F7y8y97n_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)