title: JAVA program to calculate the sum of first n even numbers starting from 0 which are divisible by 3 and print the sum
body: <p>I need java code to calculate the sum of first n even numbers starting from 0 which are divisible by 3 and print the sum.</p>
  
  <pre><code>import java.util.Scanner;
  public class Exercise1_3 {
         public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         int n=sc.nextInt();
         int sum=0;
         for(int i=0;i&lt;=n;i++)
         {
           if(i%2==0)
           {
             if(i%3==0)
             {
               sum=sum+i;
             }
           }
         }
         System.out.print(""+sum);
     }
   }
  </code></pre>
  
  <p>This code only gives me answer only up to number 10 divisible by 3 (it gives answer 6) where as i need sum of first 10 even number divisible by 3 i need answer 36.(first 10 even number are 2,4,6,8,10,12,14,16,18,20 so that sum is 6+12+18=36)</p>