title: Second array in different way
body: <pre><code>import java.util.Scanner;
  import java.util.Random;
  
  public class Ld364rmc641 {
  
  public static void main(String[] args) {
  
  double A[]=new double[20];
  double B;
  int K,i,n;
  
  Scanner sc = new Scanner(System.in);
  
  System.out.println("Ld");
  
  System.out.print("K=");
  
  if (sc.hasNextInt())
  
      K = sc.nextInt();
  
  else {
      System.out.println("input-output error");
      sc.close();
      return;
  }
  sc.close();
  if (K==0){
      Random r = new Random();
      i=0;
      while ( i&lt;20){
          A[i] = r.nextDouble()*20-10;
          i++;    
      }
  }
  else { 
      i=1;
      while(i&lt;20){
          A[0]=0.5;
          A[i]= A[i-1]+K;
          i++;
      }
  }
  System.out.println("A:");
  i=0;
  do{
      System.out.printf("%.2f\t", A[i]);
      if (i==9)System.out.println();
      i++;
  }
  while (i&lt;20);   
  for (i=0; i&lt;20; i=i+1) {
      if(i%2==0) {
  enter code here
          B = A[i];
          A[i] = A[(i+1)/2];
          A[(i+1)/2] = B;
      }
      else {
          B = A[i];
          A[i]=A[i];
      A[i]=B;
  }
  
  
  
  
  System.out.println("\nA:");
  for (i=0; i&lt;20; i++) {
      System.out.printf("%.2f\t", A[i]);
  </code></pre>
  
  <p>Needs to make the second array like this:</p>
  
  <p>A0 becomes A0</p>
  
  <p>A1 becomes A19</p>
  
  <p>A2 becomes A1</p>
  
  <p>A3 becomes A18</p>
  
  <p>A4 becomes A2</p>
  
  <p>A5 becomes A17</p>
  
  <p>And so on.</p>
  
  <p>Where is written to write code, code needs to be changed, where is penultimate for. Rest of the code is alright. Maybe someone did this task and could help me.</p>