0
How to make endless switch in java?
3 Antworten
+ 2
I think you misunderstood the instruction a bit here buddy. The task asked you to write the code that repetitively asks for input (a character) and should output arrow symbol whose pointing direction depends on the character input.
In this case, the loop may be said "endless" although not really. As you said, entering a Q character shall break the repetition, right?. So it is the input that runs in repetitions, not the `switch` conditional.
Anyways, why not share what you have tried this far in your original question Description? I might be able to help once I see how far you have gone through and where you are stuck. Hopefully you didn't expect someone to write it down for you, as that will lessen your chance for learning : )
Looking forward to see your code 👍
+ 1
Here is the task:
Write a program that will take characters in a loop:
L
U
R
D
and output in response to the entered character - the corresponding arrow:
←
↑
→
↓
The cycle should end only when the Q character is entered. Use do while loops and switch constructs. Use char characters to display arrows. Symbols:
← '\ u2190'
↑ '\ u2191'
→ '\ u2192'
↓ '\ u2193'
0
What is an "endless switch" anyway? I didn't get what you mean.