Question: Help writing these functions for the code below C++ bool isBIN8(string &) This function checks that the binary number considered is between 1 and 8

Help writing these functions for the code below C++

  • bool isBIN8(string &)

    This function checks that the binary number considered is between 1 and 8 characters long and that each character is either 0 or 1. If either check fails, the function returns false. Otherwise, true.

  • string bin2str(byte)

    This function does the reverse of the str2bin function. That is, given an unsigned char, it computes and returns the corresponding ASCII string. Use bitwise operations to determine when and how to set a bit.

  • bool isVALID(string &)

    This function implements a Boolean expression for checking that the operation is a single character which is either a '+' or a '-'. If not, the function return false. Otherwise, true.

#include #include #include using namespace std;

typedef unsigned char byte;

byte msb(byte); bool overflow(byte, byte, byte); byte twoscomplement(byte);

byte str2bin(string &); string bin2str(byte); string bin2dec(byte);

bool isBIN8(string &); bool isVALID(string &);

int main(int argc, char *argv[]) { string sX, sY; string op;

cout << "X> "; cin >> sX; if (cin.eof()) return 1;

if (!isBIN8(sX)) { cout << "error: not 8-bit binary number "; return 1; }

cout << "Y> "; cin >> sY; if (cin.eof()) return 1;

if (!isBIN8(sY)) { cout << "error: not 8-bit binary number "; return 1; }

cout << "op> "; cin >> op; if (cin.eof())

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!