Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Even Numbers in Array

$
0
0
Hi there! alright I know this is probably the simplest thing in the world but I just can't get it. Populate a 1D array with even values from 1 to 12. What I have so far complies fine but doesn't run without errors. Thank you in avdanced:



import java.util.Scanner;

public class ArrayMultiplicationTable
{
  public static void main(String[]args)
  {
    Scanner test = new Scanner(System.in);
    
    int[] a = new int[6];
    int e = 0;
    for (int i = 0; i <=12; i++)
    {
        if(i%2==0)
         {
          e++;
          a[e] = i;
         }
    }
     System.out.println(a[e]);
  }
}



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>