rendered paste bodyimport java.io.*;class Helicopter{ public static void main(String[] args) throws IOException { InputStreamReader inStream = new InputStreamReader(System.in); BufferedReader stdin = new BufferedReader(inStream); String input = "smth"; String[] tokens; int lines; int[][] coordinates; while(!input.equals("0")) { System.out.println("Fut numrin e brinjeve (jo me vogel se 4 dhe jo me te madh se 20):"); input = stdin.readLine(); lines = Integer.parseInt(input); System.out.println("Fut ciftet (gjatesia e brinjeve, drejtimi dhe ciftet te jene te ndare VETEM NGA NJE hapesire nga njeri-tjetri): "); input = stdin.readLine(); tokens = input.split(" "); for(int j = 0; j < tokens.length; j++) System.out.println(tokens[j]); coordinates = pairsToCoordinates(tokens); for(int i = 0; i < coordinates.length; i++) { for(int j = 0; j < coordinates[i].length; j++) System.out.println(coordinates[i][j] + " "); System.out.print("\n"); } } } public static int[][] pairsToCoordinates(String[] tokens) { int[][] coordinates = new int[(tokens.length / 2)][2]; int lineslength; char direction; for(int i = 1; i < coordinates.length; i++) { lineslength = 10; direction = tokens[2*i+1].charAt(0); switch(direction) { case 'M': coordinates[i][0] = coordinates[i-1][0] - lineslength; break; case 'D': coordinates[i][0] = coordinates[i-1][0] + lineslength; break; case 'P': coordinates[i][1] = coordinates[i-1][1] - lineslength; break; case 'N': coordinates[i][1] = coordinates[i-1][1] + lineslength; break; } } return coordinates; } }