forked from ronijpandey/Java-Codes
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDigitalMax.java
More file actions
41 lines (27 loc) · 805 Bytes
/
DigitalMax.java
File metadata and controls
41 lines (27 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package javacodes;
import java.util.*;
public class DigitalMax {
public static void main(String[] agrs)
{
Scanner in=new Scanner(System.in);
//User will enter a number
System.out.println("Enter a number :");
int n=in.nextInt();
int temp=0,a;
int[] arr={8,9,8,9,9,9,8,9,8,9};
while(n>0)
{
a=n%10;
temp=temp*10+arr[a];
n=n/10;
}
int ans=0;
while(temp>0)
{
a=temp%10;
ans=ans*10+a;
temp=temp/10;
}
System.out.println("Maximum no:"+" "+ans);
}
}