I am trying to write a program that wil accept a 4-digit hexadecimal number as input from the user and then output the decimal value in numeral form.
I have no idea what I am doing, I keep getting errors all over the place and this is my first time working with java.
I am suppose to use the scanner class to get a hexadecimal number and save it as a string value...but i have no idea how to do that. this is what i tried below....no clue if its even in the right boat.
any help would be appreciative.
Thank You
CODE
public class HextoDecimal {
public static int hex2decimal(String s) {
int value = Integer.parseInt(hexValue, 16);
hexValue=ABCD
;String digits = "0123456789ABCDEF";
s = s.toUpperCase();
int val = 0;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
int d = digits.indexOf(c);
val = 16*val + d;
}
return val;
}
}