Question

# Check whether the number is Bouncy number or not using only main method.

### A decreasing number is a non-negative integer in which the digits from left to right are arranged in such a way that no digit on the left is smaller than the digit to its right. For example , 3221

```				```
Enter the number
1231
1231 is a Bouncy Number
Here 1231 is neither increasing number nor decreasing number so it is a bouncy number.
```
```

# Share code with your friends

Code

```				```
import java.util.Scanner;
public class BouncyNumber
{
public static void main()
{
int num=0,temp=0,last=0,digit=0;
boolean isIncreasing=true,isDecreasing=true;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
num=sc.nextInt();
//Checking of number being negative is not required
//as it will not enter in while loop if number is negative integer
temp=num;

last=temp%10;
//This while loop is to check if the number is increasing number
while(temp>0)
{
temp=temp/10;
digit=temp%10;
if(last0)
{
isIncreasing=false;
break;
}
last=digit;
}

temp=num;
last=temp%10;
//This while loop is to check if the number is decreasing number
while(temp>0)
{

temp=temp/10;
digit=temp%10;
if(last>digit && temp>0)
{
isDecreasing=false;
break;
}
last=digit;
}
if(isDecreasing==false && isIncreasing==false)
{
System.out.println(num+" is a Bouncy Number");
}
else
{
System.out.println(num+" is not a Bouncy Number");
}
}
}

```
```

## Coding Store

Sale ### Mastering String

50
Sale 150
Sale 200
Sale ### Mastering Recursion

50
Sale ### Mastering Numbers

50
Sale ### Mastering Matrix

50
Sale ### Mastering Array

50
Sale ### ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)

50
Sale 50