使用C++对Binary Number进行算术运算。
Requirement
Read this document in its entirety and carefully before you start anything and understand it. If you have any questions, don’t hesitate to email me.
In this assignment, we will work on arithmetic of integers in two’s complement binary arithmetic. To store the two’s complement representations of integers, we will use the C++ string data type. You are not allowed to use any ARRAY variable in this assignment. Read the restriction section below.
Consider the main program given below:
1 

Your Task
The main program shown above is uploaded together with this problem statement onto Moodle under Topic 8. Download the main program code and copy and paste it to a new project. You are required to copy the given main program exactly as it is with no change whatsoever. Do not change any function signature. Then implement the missing functions so that the program works correctly. Some sample runs are given below for your reference. Of course, you can write additional helper functions that you can call from within your functions; but you are not allowed to make any change to the given main program.
Restrictions
You are required to use C++ string Data Type to represent the two’s complement binary representations. You are not allowed to use any ARRAY variable for any purpose. If you use ARRAY variable for any purpose in your program, you will automatically get zero mark.
Submission Format
You are required to submit your program online through Moodle. You will find a submission button for Assignment 2 on Moodle under Topic 7 and you are required to upload the source code of your C++ program. No assignment is submitted through email or hard copy; you must upload your work onto Moodle before the due date. Make sure to upload your .cpp file.
Marking
A nonworking program will automatically get zero. A program that works but does not give right output or gives partial right output will lose marks depending how severe its shortcoming is.
Some sample runs of the program are shown below
Remark: The user input values and the pressing of the enter key symbol are shown in red color for clarity.
Enter positive integer for the bit pattern size 5
Enter an integer a 9
Enter an integer b 14
In decimal 9 + 14 is 5
The two's complement of 9 is 01001
The two's complement of 14 is 10010
The binary sum of 01001 and 10010 is 11011
In two's complement arithmetic, 9 + 14 is 5
5 is equal to 5. Good Job!

Enter positive integer for the bit pattern size 2
Enter an integer a 100
Enter an integer b 98
In decimal 100 + 98 is 2
The two's complement of 100 is 00
The two's complement of 98 is 10
The binary sum of 00 and 10 is 10
In two's complement arithmetic, 100 + 98 is 2
2 is equal to 2. Good Job!

Enter positive integer for the bit pattern size 2
Enter an integer a 100
Enter an integer b 98
In decimal 100 + 98 is 2
The two's complement of 100 is 00
The two's complement of 98 is 10
The binary sum of 00 and 10 is 10
In two's complement arithmetic, 100 + 98 is 2
2 is not equal to 2
Either 2 cannot be represented by the given bit pattern OR we have made some mistake!

Enter positive integer for the bit pattern size 8
Enter an integer a 62
Enter an integer b 99
In decimal 62 + 99 is 37
The two's complement of 62 is 00111110
The two's complement of 99 is 10011101
The binary sum of 00111110 and 10011101 is 11011011
In two's complement arithmetic, 62 + 99 is 37
37 is equal to 37. Good Job!

Enter positive integer for the bit pattern size 5
Enter an integer a 11
Enter an integer b 9
In decimal 11 + 9 is 20
The two's complement of 11 is 01011
The two's complement of 9 is 01001
The binary sum of 01011 and 01001 is 10100
In two's complement arithmetic, 11 + 9 is 12
20 is not equal to 12
Either 20 cannot be represented by the given bit pattern OR we have made some mistake!

Enter positive integer for the bit pattern size 5
Enter an integer a 321
Enter an integer b 305
In decimal 321 + 305 is 16
The two's complement of 321 is 11111
The two's complement of 305 is 10001
The binary sum of 11111 and 10001 is 10000
In two's complement arithmetic, 321 + 305 is 16
16 is equal to 16. Good Job!

Enter positive integer for the bit pattern size 3
Enter an integer a 2
Enter an integer b 2
In decimal 2 + 2 is 4
The two's complement of 2 is 010
The two's complement of 2 is 010
The binary sum of 010 and 010 is 100
In two's complement arithmetic, 2 + 2 is 4
4 is not equal to 4
Either 4 cannot be represented by the given bit pattern OR we have made some mistake!

Enter positive integer for the bit pattern size 6
Enter an integer a 45
Enter an integer b 17
In decimal 45 + 17 is 28
The two's complement of 45 is 101101
The two's complement of 17 is 101111
The binary sum of 101101 and 101111 is 011100
In two's complement arithmetic, 45 + 17 is 28
28 is equal to 28. Good Job!

Enter positive integer for the bit pattern size 1
Enter an integer a 99
Enter an integer b 100
In decimal 99 + 100 is 1
The two's complement of 99 is 1
The two's complement of 100 is 0
The binary sum of 1 and 0 is 1
In two's complement arithmetic, 99 + 100 is 1
1 is not equal to 1
Either 1 cannot be represented by the given bit pattern OR we have made some mistake!

Enter positive integer for the bit pattern size 1
Enter an integer a 100
Enter an integer b 99
In decimal 100 + 99 is 1
The two's complement of 100 is 0
The two's complement of 99 is 1
The binary sum of 0 and 1 is 1
In two's complement arithmetic, 100 + 99 is 1
1 is equal to 1. Good Job!