Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions