Question: Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following five functionalities: Covert a binary string in

Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following five functionalities:

  1. Covert a binary string in twos complement format to corresponding integers
  2. Convert an integer to its binary representation in twos complement format
  3. Add two binary numbers, both numbers are represented as a string of 0s and 1s
  4. Provide sign extension for a binary number
  5. Provide twos complement for a binary nunber

Write a C/C++ program that simulate a menu based binary number calculator.

Code with the five functions is below. The rest of the code is too long to paste, but it shouldn't matter since these functions will work without having to change anything else in the code

______________________________________________________________________________________

string signed_extension(string s){ // you implement this one first return "0"; }

int binary_to_decimal_signed(string s){ // you implement this one third return 0; }

string decimal_to_binary_signed(int n){ // you implement this one fourth return "0"; }

string add_binaries_signed(string b1, string b2){ // you implement this one fifth return "0"; }

string twos_complement(string s){ // you implement this one second return "0"; }

This is an update of Project One. To reduce student work load, a start file CSCIProjTwo Handout.cpp is given. In this file, the structure of the program has been established. The students only need to implement the following five functions: 1. int binary to decimal signed(string b); // precondition: b is a string that consists of only Os and 1s // postcondition: the decimal integer that is represented by b 2. string decimal to binary signed(int n); // precondition: n is an integer // postcondition: n's binary representation is returned as a string of Os and 1s 3. string add binaries signed(string b1, string b2); // precondition: b1 and b2 are strings that consists of Os and 1s, i.e. b1 and b2 are binary two's complement representations of two integers // postcondition: the sum of b1 and b2 is returned. For instance, if b1 = "11", b2 = "01", then the return value is "100" 4. string signed extension(string b); // precondition: s is a string that consists of only Os and 1s that is at most 16 bits // postcondition: a 16 bit string has been returned as signed extension of s. For instane, // if s = "0101" then return value will be "00000000000000000101" total 12 IL Os are added in front of s 5. string twos complement(string s); // precondition: s is a string that consists of only Os and 1s // postcondition: two's complement of s is returned as an 16 bits binary integer. For instance, if s = "1101", then return value will be "1111111111111101" //

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!