import java.util.*; // for Scanner public class Ch14_6 // this program converts a hexadecimal number into decimal throwing a NumberFormatException if the characters of the input are not legal for a hexadecimal number (0-9, A-F are legal) { public static void main(String[] args) { Scanner s=new Scanner(System.in); String input=""; // variables used in try and finally are declared here boolean correct=true; // assume user will enter a valid hexadecimal number int value=0; // resulting decimal value try{ System.out.println("Enter a hex value and I will convert it to decimal"); input=s.next(); // user's hex value char temp; // we can declare temp here because it is not used in the catch or finally clauses for(int i=0;i