Programming Examples

Java program to check whether input number is a 5digit number or not If it is extract the central digit

Write a program to input an integer and check whether it is a 5-digit number or not. If it is extract the central digit and print it.


INPUT: Enter an integer: 76549

OUTPUT: Central digit: 5

INPUT: Enter an integer: 12976

OUTPUT: Central digit: 9

INPUT: Enter an integer: 126

OUTPUT: Not a 5 digit number


import java.util.*;
class CentralDigit
    public static void main(String arr[])
        int n,m;
        Scanner sc=new Scanner(;
        System.out.println("Enter an integer:");
        if (n>=10000 && n<=99999)
            System.out.println("Central digit:"+m);
            System.out.println("Not a 5 digit number");

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad