Can you write a code for my question please
Write a static method named displayPromptGetResponse with the following header:
public static String displayPromptGetResponse( final String PROMPT)
Using the showInputDialog of JOptionPane the method must display the string passed to it in the String parameter and return the String value returned by the showInputDialog method.
System.out be should be similar to:
PROMPT:
Enter a two digit decimal number.
Write a static method named displayOutput with the following header:
public static void displayOutput(final String OUTPUT)
Write a static method named displayTerminationMessage with the following header:
public static void displayTerminationMessage()
In this question you must use the methods displayPromptGetResponse and displayOutput as described above for all input and output. The main method must end with a call to displayTerminationMessage.
Write a java program that asks the user to enter a hexadecimal number. The hexadecimal number may contain from 1 to 3 hexadecimal digits. A hexadecimal digit is any of the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F and the decimal equivalents are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 and 15. Convert the number to decimal and display the result.
Write a method named hexDigitToInt with the following header:
public static int hexDigitToInt(final char HEX_DIGIT, final int ALTERNATE)
Write a method named fromHexToInt with the following header:
public static int fromHexToInt(final String HEX, final int ALTERNATE)
The parameter HEX holds a String of from 1 to 3 hexadecimal digits.
Set the value of ALTERNATE to -1. Request the input from the user and check that the input is not null and that the number of characters entered is valid. If not, display an appropriate message using displayOutput. It is useful to use the trim method to discard any leading and trailing whitespace from the input. If the input is valid, call fromHexToInt to convert the hexadecimal number to a decimal integer. If fromHexToInt returns the ALTERNATE value an error has occurred during the conversion and an appropriate message must be displayed, otherwise the decimal integer is to be displayed. Remember to call displayOutput to display output from the program.
Click on the Cancel button in the input dialog box. The output should be similar to the following:
PROMPT:
Enter a hexadecimal with at most 3 digits.
RESPONSE:
null
OUTPUT:
The cancel button was selected, program terminates.
Programmed by Stew Dent.
Date: Fri Sep 23 12:00:07 CDT 2011
End of processing.
Click on the OK button without entering any input into the input dialog box. The output should be similar to the following:
PROMPT:
Enter a hexadecimal with at most 3 digits.
RESPONSE:
OUTPUT:
Invalid number of hex digits, program terminates.
Programmed by Stew Dent.
Date: Fri Sep 23 12:02:20 CDT 2011
End of processing.
PROMPT:
Enter a hexadecimal with at most 3 digits.
RESPONSE:
ABCD
OUTPUT:
Invalid number of hex digits, program terminates.
Programmed by Stew Dent.
Date: Fri Sep 23 12:06:03 CDT 2011
End of processing.
Enter AbC into the input dialog box. The output should be similar to the following:
PROMPT:
Enter a hexadecimal with at most 3 digits.
RESPONSE:
AbC
OUTPUT:
AbC is not a valid hexadecimal number!
Programmed by Stew Dent.
Date: Fri Sep 23 12:10:11 CDT 2011
End of processing.