Question: In Java: Read in the number and validate with a method ( 7 points ) Your program will allow the user to specify a starting
In Java: Read in the number and validate with a method points
Your program will allow the user to specify a starting number of bottles. This number can be anywhere between and inclusive Use a loop to continue asking the user for a number until it is valid, meaning in the specified range.
Write a method that determines if the number if valid. Invoke that method to determine whether you need to keep looping.
For full credit, use constants instead of hardcoded values to make code more readable and easier to maintain.
Part Two: Print the song with words points
Write a method that prints the song starting at the user's number. Use a loop to print each verse.
Write one or more helper methods that convert a number into the words eg into "Fortythree"
For full credit, you should have no more than hardcoded Strings. All of the numbers between and can be represented with some combination of these Strings:
Ninety, Eighty, Thirty, Twenty strings
Nineteen, Eighteen, Eleven, Ten strings
Nine, Eight, One, Zero strings
Hint: think about how you can use integer division and modulus to access a number's tensplace digit and onesplace digit eg for the number is the tensplace digit and is the onesplace digit
Recommendation: Incremental Development
I strongly suggest you work on building up your program a little at a time: code and test, code and test, etc. Here is one possible approach you might use in development.
First, sketch out in wordspseudocode your approach. As part of this, write out what you think the method headers will be: the inputs, outputs, and a descriptive name. Make note of which methods you plan to call from other methods. See below for the extra credit related to this step!
Then begin coding. After each step of development, test and revise until that step is fullyfunctional
Read in and validate a user number using a method
Print out the song using numbers not wordseg bottles not Ninetynine bottles
Convert the numbers to words
Start with the numbers onlyThen add code for the numbers Finally, add code for the numbers
Note that you donot have to follow this approach. It is just a suggestion. But you should followsome plan of incremental development. Code and test small pieces at a time as you build up your full solution.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
