Hello all. So this was a code I've been working on and trying to implement another feature to this switch program. I'm trying to add a hexadecimal conversion. My try at it starts at line 74-94. I was looking at other converting codes written by other people and I know I need to install:
somewhere into my code. Also, I have to deal with unexpected inputs other than what my switch is asking for. So I have to add throwing exceptions in my code to deal with them. I have no idea how these work. Any help is great, my code is posted below.
This is a simple way to do it here. I can guarantee you it's not the most efficient but it's easy to code.
I'm sure you could work out a way to divide by 16 until 0 then loop through the remainder to get an exact value and save processor time.
Hopefully this gives you some idea on how to do it.
This basically subtracts one from the user input decimal and adds one to a hexidecimal array. Then when one of the hex array elements exceeds 15 it increments the next higher place value and sets the current place value to 0. The program loops through until user input has reached zero.