+ 1

While loop that accept int and string to stop the program .?

How can i write a code that when i input 2 numbers it will add or subtract or something and continue to ask 2 numbers until im not putting stop , stop . ? ex. 2 , 2 = 4 if i write stop stop the program will stop

3rd Dec 2017, 8:15 AM
John Nehry C. Dedoro
John Nehry C. Dedoro - avatar
2 ответов
+ 1
Thats where do while loop comes into play. So basically when you use a do while loop you want to run the execution at least once and then run again depending upon the condition. If the condition evaluates to true it is repeated again. So syntax of do-while loop: do { -------(lines of code) }while( condition ) in the condition part, you can ask for user input and then according run your do while loop for more information i recommend you to google it
3rd Dec 2017, 8:24 AM
RR2001
RR2001 - avatar
0
string s= stop; string input; if (input.compareTo(s)) { break; } // it will simply stop the loop.
3rd Dec 2017, 8:27 AM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar