You are to write a numerical base converter. This application will present the

user with a menu to select the originating base and a subsequent menu to select

the destination base. You will loop through these menus until the user wishes to

quit.

You are required to break the code into logical functions (eg. a function that

converts to hexadecimal, another function to convert to binary, etc.).

Notes

• The code for this assignment will be more rigorously graded than for

assignment #1.

• You will need arrays to validate the input. You may choose to use arrays

to display the output – but it is not necessary.

• The **atoi() **C function is very useful for this assignment. Investigate it.

• It is recommended to take the numbers in as a string, validate each

character based on the base required (e.g. 3G4 is not a valid hexadecimal

value, nor is 21 a valid binary).

• Based on what happened in assignment #1, start early and **ask
questions.**• Refer to the submission standards.

Sample Output:

**Please select a base to start:**

1) Decimal

2) Hexidecimal

3) Binary

Selection: 3

Please enter a value: 2

That is invalid, please enter a value: 101

Please select a base to convert to:

1) Decimal

2) Hexidecimal

3) Binary

Selection: 1

Binary 101 converts to Decimal 5.

Would you like to do another conversion? Y

CST8811:

1) Decimal

2) Hexidecimal

3) Binary

Selection: 3

Please enter a value: 2

That is invalid, please enter a value: 101

Please select a base to convert to:

1) Decimal

2) Hexidecimal

3) Binary

Selection: 1

Binary 101 converts to Decimal 5.

Would you like to do another conversion? Y

Programming II

Assignment #2

Assignment Two – Numerical

Conversions

Page 2 of 2 ©2007 Algonquin College

Shawn Unger

02-CST8811-Assignment-Two.doc

**Please select a base to start:**

1) Decimal

2) Hexidecimal

3) Binary

Selection: 2

Please enter a value: 2F

Please select a base to convert to:

1) Decimal

2) Hexidecimal

3) Binary

Selection: 3

Hexadecimal 2F converts to Binary 00101111.

Would you like to do another conversion? N

1) Decimal

2) Hexidecimal

3) Binary

Selection: 2

Please enter a value: 2F

Please select a base to convert to:

1) Decimal

2) Hexidecimal

3) Binary

Selection: 3

Hexadecimal 2F converts to Binary 00101111.

Would you like to do another conversion? N