Question: Write a program that asks the user to input a number in binary format and converts it to its decimal (integer) equivalent. Assume that only
Write a program that asks the user to input a number in binary format and converts it to its decimal (integer) equivalent.
Assume that only positive whole numbers are input.
Your program must:
1. Ask the user to enter the number in binary format.
2. Check to see that the number entered is actually in binary format (starts with a '1' and only has '0's and '1's).
- If you find the user input something that is not correct, then ask the user to reenter the number. Make sure you respond appropriately so the user has some idea of what went wrong.
(Think carefully about how you will go about doing this check. This kind of check as we have discussed in class is called Input Validation.)
3. Convert the number: This must be done using a method. The actual conversion must be a method that takes the binary number as a parameter and returns the integer as a result.
4. Display the result.
5. Ask the user if the user wants to enter another number for conversion:
- If yes, then repeat from step 1.
- If no, then terminate the program by saying "Goodbye!"
Before beginning to code, develop your logic first. Describe how you would do this, as algorithm/pseudocode/flowchart. (This will be worth 60 points.) Think carefully about what you need to do. Refer to page 2 of this document regarding some notes on binary-to-decimal conversion. Break down the steps first and then proceed to write out how you would go about converting. Keep an eye on all loops that you might/might-not need.
Develop and show at least 3 test cases; including an incorrect case.
Submission:
Submit a document including the above, and screenshots of running program and results. Include the complete Source Code as part of the document at the end. If you are unable to complete the problem submit all the work you have done.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
