Computer Science, asked by SourabhSM1, 10 months ago

Please answer this. 19. 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.
Example
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​

Answers

Answered by dhargoutam11
16

import Java. util. * ;

class Fivedigit

{

public static void main ( String Args [] )

{

int a ;

Scanner Sc = new Scanner ( System. in) ;

do {

System. out. println (" Enter a no. ) ;

a = School. nextInt () ;

if ( a < 9999 )

System. out. println ( " Not a five digit no. " ) ;

} while ( a>9999 ) ;

int r = ( int) ( a % 1000 ) ;

int answer = ( int) ( a / 100 ) ;

System. out. println ( " The middle digit is " + answer) ;

}

}

Similar questions