Byte b;
Requirements () function converts a decimal number I hex 0 and assign a value to the byte type b, which requires to get the following results:
B=0 x0a;
CodePudding user response:
A face of meng force
CodePudding user response:
import java.util.Scanner;Public class Main {
Public static void main (String [] args) {
Scanner Scanner=new Scanner (System. In);
String String=scanner. NextLine ();//input hexadecimal number
int sum=0;
for(int i=0; i
Int m=string charAt (I);//the input hexadecimal string into individual characters
Int num=m>='A'? M - 'A' + 10: m - '0';//will turn numerical characters corresponding to the ASCII value of the
Sum +=math.h pow (16, string. The length () - 1 - I) * num.
}
System. The out. Println (sum);
}
}
CodePudding user response: