Program 2 Solution

$29.99 $18.99

Write a program in VS C++ 2017 to convert a signed integer to its binary equivalent (8 bits) (in 2’s complement) and vice versa. Your program should first read in either a signed integer or a binary number (always in 2’s complement) provided by the user. Your program then does the necessary conversion and displays…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product

Write a program in VS C++ 2017 to convert a signed integer to its binary equivalent (8 bits) (in 2’s complement) and vice versa. Your program should first read in either a signed integer or a binary number (always in 2’s complement) provided by the user. Your program then does the necessary conversion and displays the answer to the screen. The following shows a scenario of running a sample program, where user’s inputs are represented in boldface.

Enter your choice (1 = decimal to binary, 2 = binary to decimal): 1

Enter the signed decimal number to be converted: –23

The binary equivalent for the signed decimal number -23 is 11101001

More choice (y or n): y

Enter your choice (1 = decimal to binary, 2 = binary to decimal): 2

Enter the binary number to be converted: 00110101

The signed decimal equivalent for the binary number 0110101 is 53

More choice (y or n): y

Enter your choice (1 = decimal to binary, 2 = binary to decimal): 2

Enter the binary number to be converted: 11011010

The signed decimal equivalent for the binary number 11011010 is -38

More choice (y or n): n

Good bye!

Follow the criteria shown below to prepare and turn your program in to Canvas.

  1. You MUST use VS C++ 2017 to develop, compile, debug, test, and run your program.

  1. Submit only the source-code file to Canvas (on time or late).

  1. Make sure your program compiles successfully in order not to lose a major portion of total points.

  1. You may assume the signed decimal number to be converted is always small enough to be contained in 8 bits.

  1. All of the binary numbers entered are represented in 2’s complement form.

  1. Your program will be tested using the test cases similar to those shown above.

Page 1 of 1