Reputation: 279
I've a 2D array with speific size (e.g. 50) filled with . (points), I'm tyring to understand this issue :
The programs asks for the horizontal and vertical distances (these are 2 numbers) and the starting character, draws 2 “lines” into the array, starts from the lower-left and from the lower-right corner! Then the program displays the array.
//We declare a 2D array with size of 50
char[][] coordSystem = new char[50][50];
//Fill the array with "." (point)
for (int row = 0; row <= coordSystem.length - 1; row ++) //first loop for row
for (int col= 0; col<= coordSystem.length - 1; col++) //second loop for column
coordSystem[row][col] = '.';
// Our program asks for the horizontal and vertical distances and the starting character.
Scanner scanner = new Scanner(System.in);
System.out.print("Please type the horizontal distance : ");
int horizontalDistance = scanner.nextInt();
System.out.print("Please type the vertical distance : ");
int verticalDistance = scanner.nextInt();
System.out.print("Please type the starting character : ");
char startChar = scanner.next().charAt(0);
output should look like this : Example:
Please type the horizontal distance: 5
Please type the vertical distance: 2
Please type the starting character: E
....................I........I....................
..................................................
...............H..................H...............
..................................................
..........G............................G..........
..................................................
.....F......................................F.....
..................................................
E................................................E
Thank you for your help.
Upvotes: 1
Views: 151
Reputation: 68
I think that horizontal distance is just distance that letter should "travell" after every iteration. And vertical distance is just how many rows you should skip. Starting character is just a letter, which will be written in the array and seems like after each iteration it should decrease in alphabetical order, while it doesn't become A, I suppose.
Upvotes: 1