Question: Programming Exercise 2 (12 points): Write a program that prompts the user to enter a character c that represents a hexadecimal digit (recall that c
Programming Exercise 2 (12 points): Write a program that prompts the user to enter a character c that represents a hexadecimal digit (recall that c can be "O,,, l,", '2,,, . . . . , "8,,, 9,,, A', B', C,,, D,,, E,,, or ..f"). Your program must use the character type for the input. If the user enters a character "x" that is not a hexadecimal digit, you must print out the following error message: "The character x is invalid: x is not a hexadecimal digit." If the character c is a hexadecimal digit, your main program must print out its value in decimal. Example l: If the user enters the character "4," your program must print out the value 4 Example 2: If the user enters the character "B," your program must print out the value I1. Example 3: If the user enters the character "E," your program must print out the value 14 Example 4: If the user enters the character "L," your program must print out the following error message: "The character I is invalid: I is not a hexadecimal digit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
