display even and odd numbers in java using for loop

Solutions on MaxInterview for display even and odd numbers in java using for loop by the best coders in the world

showing results for - "display even and odd numbers in java using for loop"
Erik
05 Jul 2020
1import java.util.Scanner;
2public class FindEvenOrOdd
3{
4   public static void main(String[] args)
5   {
6      int a;
7      Scanner sc = new Scanner(System.in);
8      System.out.println("Please enter a number to check even or odd: ");
9      a = sc.nextInt();
10      if(a % 2 == 0)
11      {
12         System.out.println("Entered number is an even number.");
13      }
14      else
15      {
16         System.out.println("Entered number is an odd number.");
17      }
18      sc.close();
19   }
20}
Tommaso
03 Mar 2020
1// even and odd numbers in java using for loop
2import java.util.Scanner;
3public class EvenOddUsingForLoop
4{
5   public static void main(String[] args)
6   {
7      int a;
8      Scanner sc = new Scanner(System.in);
9      System.out.println("Enter number(max) to print all even and odd until: ");
10      int number = sc.nextInt();
11      System.out.println("Even numbers from 1 to " + number + " are: \n");
12      for(a = 1; a <= number; a++)
13      {
14         if(a % 2 == 0)
15         {
16            System.out.print(a + "\n");
17         }
18      }
19      System.out.println("Odd numbers from 1 to " + number + " are: \n");
20      for(a = 1; a <= number; a++)
21      {
22         if(a % 2 == 1)
23         {
24            System.out.print(a + "\n");
25         }
26      }
27      sc.close();
28   }
29}
queries leading to this page
check if number is odd in javacheck odd in javahow to check if a number is even in javajava program to check even or odd numberhow to check if a value is odd in javawrite a java program to check whether the given number is even or oddprogram to check whether a number is odd or even in javajava program to check even or odd integerscheck if number is even or odd javaeven or odd javajava even number programodd even in java using for loophow to find the odd number and even if condition in javahow to use a for loop to determine even and odd numbers in javafind odd number in javaeven number check in javajava number oddcheck even and odd in javaeven odd program in java using if elseodd even code javacondition for odd and even numbers in javahow to count even and odd numbers in javaeven odd program in java using methodeven odd program in java using functionnumber is odd in javajava is number oddhow to check a number is even in javahow to make a loop for odd number javaodd and even numbers in java using if elsehow to find out if a number is odd in javaeven or odd numbers in java simple programhow to check if even or odd in javajava expression that a number is oddhow to check if a number is even or not javaeven and odd numbers in javadisplay even numbers in java using for loophow to print even and odd numbers in javashow only odd numbers java while loophow to find if a number is even in javacheck if a number is odd javaeven and odd numbers in java codefind odd no program in javajava if evenjava even numberswrite a program to find whether the number is even or odd in javaeven checker javahow to check odd number in javaevendigits take out the odd number javacode even number in javahow to know if it an odd number javajava check if a number is oddjava even or oddodd or even number javajava program for odd numbers till nhow to check if value is odd javajava check odd evenhow to check size if number is odd javanumber even or odd javaodd and even number in javafind even number in javajava how to check for odd or evenodd number in javajava check for odd numberjava code to finding the odd numberfind a number is even or odd from taking input in javaodd even program in javaprogram to check whether a number is even or odd using switch javacode to check if given number is odd or even in javahow to find a even numbers in javaloop to check if a number is odd javahow to check even number in javahow to specify odd numbers in javaif x is odd javaeven and odd code in javahow to check if a number is odd in javadisplay even and odd numbers in java using for loopcheck whether number is odd or even in javaeven number in java programhow to display odd numbers using loop in javahow to find an odd number in javahow to check if int is odd or even javahow to find odd number in java if elsehow to get even and odd numbers in javaif odd number javaodd number on javawrite a program in java to check number is even or oddeven or odd number program in javaeven 2fodd numbers in javajava check int is oddjava program to check whether a number is oddjava how to check for an even numbveris odd number javajava odd number checkhow to know odd number javaif number is even javajava check if number is even or oddhow to determine if a number is even or odd in java 27logic for even number in javahow to find odd numbers in javaprint odd and even numbers in javafunction to even odd number javajava 25 for odd integersprogram to find odd or evenprogram java odd or even number is even or odd using bit javawrite a java program to find out the number is even or odd in javajava program to return if number is even or oddhow to get the even and odd number using a for loop javajava check if number is paircheck even or odd in javawrite a program to count even and odd numbers from an inteeger in javahow to tell whether a number is even or odd in javajava program to check if number is even even odd number in javafind even odd number in javachecking if a number is odd javahow to find odd or even numbers javajava even or odd methodeven number javaodd number program in javaeven odd program in java simplehow to print odd numbers in java using while loophow to know odd number and even number javahow to calculate odd numbers in javajava odd numbercode to see if number is even javafind odd number javajava check number is oddjava program to check if number is odd or evencheck if a number is even or odd javajava how to check for an odd numberodd or even javawap in java to check whether a number is even or oddwrite a program in java to find out if a number is odd or even in java using scannerodd numbers java programhow to check for even numbers in javafind odd or even in javawrite a program in java to check whether a number is odd or eveneven numbers javajava how to check if a number is oddodd numbers in javaa method in java to identify a number if it is odd or evenwrite a program to count even and odd numbers in javafind even number or not javahow to find an odd number in java if elsejava determine if number is oddodd numbers in java using for loopodd numbers program in javaodd numbers loop javajava if odd numberhow to check number is odd in javaloop odd numbers javaodd even number javaeven number in javacheck number odd or even javawrite a program to find whether the number is odd or evencheck whether a number is odd in javachecking string if odd or even in javawrite a program to check a given number is even or odd javajava if number is evenhow to get odd numbers in javacheck if odd or even javagenerating even and odd number in javajava int is odd or evenfinding odd numbers in javaeven or odd in javahow to find the even number in javaprogram to check even or odd in javaeven number and odd numbers java else statementodd even check in javafind if number is odd javan odd numbers javahow to calculate odd and even numbers in javacheck odd and even in javajava odd or even loopjava program to find odd or evenwrite a java program to check whether a given number is even or odd odd numbers with javaeven odd function in javaif condition odd or even in javajava is number odd or evenjava check if int is even or oddeven or odd numbers javahow to create check odd number in javahow to check for odd numbers in javaodd numbers by for loop in javahow to check if the number is not odd javajava for loop to display even numbershow to check even odd in javaodd and even code in javajava check number is evenodd number javaif number is odd javawrite a program to print even and odd numbers in java using for loophow to check for an odd number in javahow to check if a number is even or odd in javajava odd or evenjava int is evenodd even program javajava if else number is oddeven numbers in java programhow to check if the number is odd javachecking if in integer is odd in javamethod to see if a number is odd in javaodd or even program in javaprint even and odd no in javajava even or odd functionfind the number is odd or even in javaprint whether given number is even or odd in javajava function for odd or evenhow to know if a number is even in javawrite a program in java to check if a number is even or odd checking if something is odd javajava number is oddodd number logic in javacan you check if a number is even or odd javahow to check if an int is even or odd in javato print whether given number is even or odd in javajava for loop odd numbershow to check for odd number in javachek if a number is odd javajava if a number is even orodd or even in javacheck if number is even javaevenodd numbers javaeven odd program in javahow to check if number is odd or even javahow to determine if a number is even or odd in javaodd and even numbers finder javaodd number java if statementjava program to check number is even or odd by using 26 operatoreven or odd function javajava odd number loopeven odd algorithm javacheck for even number javajava how to check if int is odd or evenwrite a java program given number odd or evenjava even odd programeven or odd number in javahow to check if number string has odd or even javaeven and odd number javajava check if odd or evenjava program to find even numbersjava how to check a number is even or oddjava check if number is oddodd numbers javajava odd even programcheck for odd number javafind odd and even number in javahow to tell if a number is odd javajava odd number programodd coding in javahow to get even numbers in a for loop javaif number is odd or even javahow to check even numbers in javaeven or odd numbers in javaprogram to check no is odd or not in javafuction to check given number is odd or even in javaeven and odd numbr in javahow to determine if a number is even or odd in java with modulouscalculate odd number in javaodd number in java 27 5ccheck if number is odd javahow to check if number is even in javahow to find if a number is even or odd in javacheck if number is odd or even javafind even and odd numbers in javaeven number in javahow to get odd numbers while loop javahow to test if a number is odd javan is even or odd javafind even number javacount odd and even numbers in javahow to check even or odd in javacheck even number in javaeven or odd program in javadisplay even and odd numbers in java using for loop