Write a C++ program that reads characters representing binary (base-2) numbers from a data file ( [login to view URL] ) and translates them to decimal (base-10) numbers. The binary and decimal numbers should be output to the screen as well as to a file [login to view URL] in two columns with appropriate heading.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request.
3) Complete ownership and distribution copyrights to all work purchased.
Program 3
Write a C++ program that reads characters representing binary (base-2) numbers from a data file ( [login to view URL] ) and translates them to decimal (base-10) numbers. The binary and decimal numbers should be output to the screen as well as to a file [login to view URL] in two columns with appropriate headings. Here is a sample output file:
Binary Number Decimal Equivalent
1 1
10 2
11 3
10000 16
10101 21
There is only one binary number per input line, but an arbitrary number of blanks can precede the number. The program must read binary numbers one character at a time. As each character is read, the program multiplies the total decimal value (which begins at 0) by 2 and and adds either 1 or 0 depending upon the input character. The program should check for bad data; if it encounters anything except a 0 or 1, it should output the message "Bad digit on input" and proceed to the next binary number.
Use a function to convert Binary to Decimal. The function should read in a binary number (from a single line in the file) and return its decimal equivalent. In addition, the function should accept a reference parameter of type string, which is modified to reflect the binary number read in. The function prototype should be:
int binToDec(string &binary);
For example, when the fuction is called the very first time, it returns the integer 43 and the reference parameter binary contains 101011 (see the file [login to view URL])
Your program will be graded on the following:
Accuracy (does it produce desired output?)
User-friendliness (are you printing out legible messages and prompts?)
Program Style - comments, indentation, named constants
What you need to turn in:
A printout of the source file, a printout of the output, and a printout of the file results.txt. Include the name of each file in your turn-in.
## Platform
This C++ program needs to run through Unix