Question: A C + + program to convert 5 - digit numbers from binary to decimal. In this assignment, you will expand on that program so

A C++ program to convert 5-digit numbers from binary to decimal. In this assignment, you will expand on that program so that it can calculate binary numbers of unlimited size. Prompt the user for 1s and 0s until they enter a -1. For each digit entered of the binary number, perform the part of the conversion that number represents (you will need to keep track of which digit position you are currently converting). After the user enters -1, display the converted binary number.
Input Validation
You will need to ensure that the digits provided by the user are either 1,0, or -1 and that the user hasn't caused input failure. If there is a problem with the input, you will need to take appropriate action and re-prompt for new data.
Sample Output
Welcome to the binary number converter 2.0.
You will enter a binary number 1 digit at a time starting at the right and the program will convert the number to decimal.
Enter the 1st binary digit (Enter -1 to complete the conversion): 0
Enter the 2nd binary digit (Enter -1 to complete the conversion): 1
Enter the 3rd binary digit (Enter -1 to complete the conversion): 2
A binary digit can only be a 1 or 0.
Enter the 3rd binary digit (Enter -1 to complete the conversion): 1
Enter the 4th binary digit (Enter -1 to complete the conversion): a
You entered something that is not a number.
Enter the 4th binary digit (Enter -1 to complete the conversion): 1
Enter the 5th binary digit (Enter -1 to complete the conversion): 0
Enter the 6th binary digit (Enter -1 to complete the conversion): -1
Your number in decimal is 14

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!