Computer Science, asked by dawnsaptarshi, 6 months ago

Write a program in java to input an integer and check whether it is a 2-digit or a 3-digit number or not. In case it is not a 2-digit or a 3-digit number a relevant message (“Not 2 or 3 digit number”) should be displayed

Answers

Answered by anindyaadhikari13
9

Question:-

Write a Java program to input an integer and check whether it is two digit or a three digit number. In case it's not a 2 digit or 3 digit number, display the message that it is not a 2 or 3 digit number.

Program:-

import java.util.*;

class Number

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

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

int n=Math.abs(sc.nextInt());

if(n>=10&&n<100)

System.out.println("Its a 2 digit number.");

else if(n>=100&&n<1000)

System.out.println("Its a 3 digit number.");

else

System.out.println("Not a 2 or 3 digit number.");

}

}

Answered by gomessomali
0

Answer:

fjdjdjdjjdjfjddidususuusudididididiid

Similar questions