Fill This Form To Receive Instant Help
Homework answers / question archive / The Problem that needs solving is to be able to generate and display numbers in different bases
The Problem that needs solving is to be able to generate and display numbers in different bases. To accomplish thsis you will design and implement a base conversion program that uses a menu to query the user from a menu of four options for generating and converting numbers from one base to another.
The first option is to generate and display a random number in a user selected base, as well as its base 10 equivalent.
The second option is to generate and display a random number in a user selected base, and then convert and display that number in a target base, also selected by the user.
The third option is to ask the user for a numeric input in a user selected base. The user will then select a target base to convert to and the program will display the conversion result.
The fourth option is to exit the program.
You must use Python to implement this program solution.
The solution must be submitted as an Eclipse IDE zipped project.
You must include your IPO Charts and algorithms.
You will need a main algorithm for the main logic structure of the program and an algorithm for each of the functions you define.
The program must allow the user to continue selecting from the menu until they select the quit option.
The program should not fail if the user enters invalid values. See the example below.
Note that this problem has many common processes among the choices and is to be solved using functions that implement those common processes.
The following is a list of functions that correspond to most of the common processes, and which will need to be implemented:
convertNumberToBase10(STRING pNumberString, INTEGER pBase): returns the base 10 integer value of the input string number. Example: convertNumberToBase10('FF', 16) would return INTEGER 255
(This is the intermediate base value from which all other bases can be generated.)
generateRandomBaseNumber(INTEGER pBase): returns a valid randomly generated number, as a string, in the chosen base.
getInteger(): returns a valid INTEGER value from the user
getBaseFromUser(): returns an INTEGER number for the chosen base
convertToNewBase(INTEGER p10Number, INTEGER pBase): returns a string of digits in the appropriate base.
getNumberFromUser(INTEGER pBase): returns a string of digits in the appropriate base.
The following is an example of the output of a program that solved and implemented a solution to the above problem.
Select from one of the following menu options.
1) Generate random number in a base of your choice.
2) Generate random number in a base of your choice and convert it to another base also of your choice.
3) Enter a number in a selected base and convert it to a base of your choice.
4) Quit Program
Please enter 1, 2, 3, or 4
8
8 is an invalid menu choice.
Select from one of the following menu options.
1) Generate random number in a base of your choice.
2) Generate random number in a base of your choice and convert it to another base also of your choice.
3) Enter a number in a selected base and convert it to a base of your choice.
4) Quit Program
Please enter 1, 2, 3, or 4
1
What base would you like to use for your new number?
Please select a base value from 2 to 36.
1
Please select a base value from 2 to 36.
2
10001010101011 is a randomly generated number in base 2 and is equal to 8875 base 10.
Select from one of the following menu options.
1) Generate random number in a base of your choice.
2) Generate random number in a base of your choice and convert it to another base also of your choice.
3) Enter a number in a selected base and convert it to a base of your choice.
4) Quit Program
Please enter 1, 2, 3, or 4
2
What base would you like to use for your new number?
Please select a base value from 2 to 36.
16
The generated number is BDD base 16.
We will convert that number to a new base.
What base would you like to use for your new number?
Please select a base value from 2 to 36.
99
Please select a base value from 2 to 36.
10
BDD base 16 is equal to 3037 base 10.
Select from one of the following menu options.
1) Generate random number in a base of your choice.
2) Generate random number in a base of your choice and convert it to another base also of your choice.
3) Enter a number in a selected base and convert it to a base of your choice.
4) Quit Program
Please enter 1, 2, 3, or 4
f
f is an invalid menu choice.
Select from one of the following menu options.
1) Generate random number in a base of your choice.
2) Generate random number in a base of your choice and convert it to another base also of your choice.
3) Enter a number in a selected base and convert it to a base of your choice.
4) Quit Program
Please enter 1, 2, 3, or 4
3
What base would you like to use for your new number?
Please select a base value from 2 to 36.
1
Please select a base value from 2 to 36.
ue
Please select a base value from 2 to 36.
2
Please enter your number as a base 2 number.
Your numeric digit choices for your number are 01.
1234
1234 is not a value in base 2.
Your numeric digit choices for your number are 01.
1101
You entered the number 1101 base 2.
We will convert that number to a new base.
What base would you like to use for your new number?
Please select a base value from 2 to 36.
16
1101 base 2 is equal to D base 16.
Select from one of the following menu options.
1) Generate random number in a base of your choice.
2) Generate random number in a base of your choice and convert it to another base also of your choice.
3) Enter a number in a selected base and convert it to a base of your choice.
4) Quit Program
Please enter 1, 2, 3, or 4