These are the steps the program must follow:
- Request user input for 4 digit pin. [done]
- Convert 4 digit pin to hexadecimal. [?]
- Generate two random numbers greater than 1000 and convert to hexadecimal.[?]
- Sandwich the converted pin between the two random converted numbers. [can be done]
So far the code I have is:
public static void main(String[] args)
{
int digit = 0;
Scanner scan = new Scanner(System.in);
System.out.println("Please enter a four digit pin:");
digit = scan.nextInt(); // scanning for user input
String Hexpin =Integer.toHexString(digit);
System.out.println(Hexpin);
}
I currently need help converting the pin to hexadecimal and generating two random numbers greater than 1000 and converting them to hexadecimal also. I can then however do the sandwich easily. I tried searching for an answer before this and cant find anything other than:
C# convert integer to hex and back again
This article however converts the int to a hex string not a decimal.