Home > Back-end >  Java using a recursive implementation of binary decimal how to write?
Java using a recursive implementation of binary decimal how to write?

Time:10-04

Java using a recursive implementation of binary decimal how to write?

CodePudding user response:

The basic question to your search

CodePudding user response:

Import the Java. IO. *; Public class Max {public static void main (String args []) {BufferedReader reader=new BufferedReader (new InputStreamReader (System. In)); Try {System. Out. Println (" please enter 8 hexadecimal number 2 "); The String line=reader. ReadLine (); int sum=0; Int sum1=0; for(int i=0; i<8; I++) {char c=line. The charAt (I); If (c=='1' & amp; & C<'2') {sum=1; for(int j=0; j<7 - I; J++) {sum *=2; Sum1 +=sum; }}} System. Out. Println (" decimal result is "+ sum1); } the catch (IOException e) {System. Out. Println (e); }}}
  • Related