Paul Clapham wrote:So if the number is 1 you want to output "bottle", else you want to output "bottles"?
Does what I wrote there suggest any Java code?
Campbell Ritchie wrote:And welcome to the Ranch
Amir Ahmed wrote:Any idea how to write the code with using do while loop only?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:
Amir Ahmed wrote:Any idea how to write the code with using do while loop only?
Why don't you want to use Paul's suggestion? There is a statement that lets you do EXACTLY what you want. Someone suggests using it, and your response is that you want to do it using a statement that does NOT do what you want to do...
That's just odd.
Amir Ahmed wrote:its my professors requirement that we use only do while. Nothing else.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
So what did you do to fix it?
Tony Docherty wrote:
So what did you do to fix it?
Welcome to the Ranch.
Please don't tell me you have the same ridiculous requirement to solve this only using a do-while statement.
Sorry for the late response Tony, below is how i fixed it.
Tony Docherty wrote:
Sorry for the late response Tony, below is how i fixed it.
I'm glad to hear you solved it, but that isn't a solution using only while loops as you have used the tenary operator. Mind you, it is a good way to do it as, has already been said, restricting the solution to just while loops is ludicrous.
BTW make sure you format your code correctly, your 'while' statement appears to belong to the final set of curly braces when in fact it belongs to the set of curly braces immediately following the 'do' keyword. And please use code tags when posting code