The advent of computers dawned on the age of programming languages. With time, multiple languages such as Java were developed in order to proceed with coding and hence communicating with computers to perform desired functions. At present, students are overwhelmed with the technicalities of Java and the many resources available to help them with their work. We at assignmentstudio promise to provide you with high-quality service and the best possible programming tutor available.
What is Java?
First developed in 1995, Java was created as a programming language. In today’s digital age, especially with fintech products and services, Java has become the backbone of computing platforms all over the world. It is owned by Oracle, and today almost 3 billion devices run Java.
Find the Even and Odd Numbers
import java.io.*;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
//Take input from the user
Scanner sc=new Scanner(System.in);
int n;
System.out.println(“Enter the Number “);
n=sc.nextInt();
System.out.println(“The Even Elements are…”);
for(int i=0;i<n;i++)
{
if(i%2==0) //Check whether even or not
{
System.out.print(i+” “);
}
}
System.out.println(” “);
//Print the odd elements
System.out.println(“The Odd Elements are…”);
for(int i=0;i<n;i++)
{
if(i%2!=0) //check whether odd or not
{
System.out.print(i+” “);
}
}
}
}