Enquiries for if-else statement structure | Sololearn: Learn to code for FREE!


Enquiries for if-else statement structure

I want to design an choice program for user. I have designed something like this, there is no last "else" because ans D is to exit the loop without printing anything. do { If ( ans == A) {} else if ( ans == B) {} else if (ans == C) {} } while ( ans != D); Is my design very weird ? Or there is any suggestion in terms of design. (please take note option D is just exit)

4/15/2022 8:11:46 AM


2 Answers

New Answer


No, it just fine if you use equals() method https://www.sololearn.com/Discuss/3016658/?ref=app https://www.sololearn.com/discuss/3016143/?ref=app


Use switch cases..