ACT5C_Mayor_2

Please don't copy paste!
mail@pastecode.io avatar
unknown
java
2 years ago
440 B
19
Indexable
Never
package com.ACT5C_Mayor_2;

public class ACT5C_Mayor_2 {

    public static void main(String[] args) {
        // Declaring variable
        int evenSum = 0;
        // For loop Statement
        for (int m = 1; m <= 15; m++)
            if (m % 2 == 0)
                // Formula
                evenSum = evenSum + m;
                System.out.println("The sum of all even numbers from 1 to 15 is " + evenSum);

     }
}