Page 600 - Computer science 868 Class 12
P. 600
3 {
4 Scanner sc = new Scanner(System.in);
5 long bin , dec;
6 int p=0;
7 Binary()
8 {
9 bin=dec=0;
10 p=0;
11 }
12 void readBin()
13 {
14 System.out.println("ENTER A BINARY NUMBER");
15 bin= sc.nextLong();
16 }
17 long convertDec(long a)
18 {
19 if(p==0)
20 bin=a;
21 if(a==0)
22 return dec;
23 else
24 {
25 dec=dec+(long)Math.pow(2,p)*(a%10);
26 p++;
27 return convertDec(a/10);
28 }
29 }
30 void show()
31 {
32 long t=bin;
33 long z=convertDec(t);
34 System.out.print("BINARY NUMBER:"+bin+"\nITS DECIMAL EQUIVALENT:"+dec);
35 }
36 public static void main()
37 {
598598 Touchpad Computer Science-XII

