➽ Program:-

import java.util.*;

import java.io.*;

public class Main

{

    public static void main(String args[])

    {

        int i, number, even = 0, odd = 0;

        Scanner s = new Scanner(System.in);

        number = s.nextInt();

        System.out.print("Enter a Number: ");

       

        for(i = 0; i <= number; i++)

        {

            if(i % 2 == 0)

            {

                even = even + i;

            }

            else

            {

                odd = odd + i;

            }

        }

       

        System.out.print("Sum of all Even Numbers: "+ even);

        System.out.print("Sum of all Odd Numbers: "+ odd);

    }

}

➽ Output:-

Enter a Number: 50
Sum of all Even Numbers = 650
Sum of all Odd Numbers = 625