In lieu of the usual mouse or trackpad or similar device, thenumeric keypad can
ID: 3616302 • Letter: I
Question
In lieu of the usual mouse or trackpad or similar device, thenumeric keypad can be used to movethe cursor. As such, the numbers could indicate the direction thatthe cursor is supposed to move.
Create a program that will read one number at a time and showcursor movement on an 8x8 board
depending on the number entered. Make sure that the cursor does notget off the board. Set the
upper left hand corner of the board as the starting point of thecursor.
For reference, use the following number-direction assignment:
7 for
Up-left
8 for
Up
9 for
Up-right
4 for
Left
5 for
QUIT
6 for
Right
1 for
Down-left
2 for
Down
3 for
Down-right
Sample Run
C:java Cursor
@ - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
Move: 2
- - - - - - - -
@ - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
Move: 9
- @ - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
Move: 8
- @ - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
Invalid move.
Move: 5
THE END
Explanation / Answer
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.