Answered step by step
Verified Expert Solution
Question
1 Approved Answer
hey so ive been attempting fo program this assignment but cant wrap my head around how to successfully code this given the requirements. I finally
hey so ive been attempting fo program this assignment but cant wrap my head around how to successfully code this given the requirements. I finally got code fo run that will convert a binary number to decimal and vice versa. However the part that im sfill confused about is padding to the nearest nibble. For this asignment I also have to convert a character to an int and read in each digit with cin.get(). I am also not allowed fo use arrays or strings which makes this even more difficult to solve. Help would be greatly appreciated. Thank you. Heres the problem:
Binary to Decimal / Decimal to Binary READ ME (Chapter 3) Purpose: . Read in a binary string one character at a time, convert it to decimal. Convert the decimal number back to binary and it should be the same as the original input. Print the binary string padded to the nearest nibble (4 bits). there must be a space between each nibble. start Read binary string and produce a deimal number dec print binary representation of dec repeat? cin.ignore)end Notes: . DO NOT use arrays or strings for this project . You should know how to convert a character digit to a numerical digit: '1-> 1 to read a binary string one character at a time, use a cin.get0 loop to pad to the nearest nibble, you must find the largest number of the form 2A(4i-1) that is smaller than dec. Use this number to convert the decimal number: o if your power of 2 is 8, it yields a 4 bit number [8-2 (4 1-1)] o if your power of 2 is 128, it yields an 8 bit number [128 2 (4 2-1)] o if your power of 2 is 2,048, it yields a 12 bit number [2,048 2 (4 3-1)] o if your power of 2 is 32,768, it yields a 15 bit number[32,768 2 (4 4-1)] o You must have a block in your program that will calculate this power of 2. . in order to place spaces between each two nibble: 1110 0011, you must count the bits that are being processed. So, you need a block in your program that counts the bits and manages the printing of the spaces Expected Output: CALL VERIFIED] CENDING IN A ZERO BITJ bin: 110 is 6 in decimal notation which is equal to: 0110 again? y CENDING IN A ONE BIT] bin: 11011 is 27 in decimal notation which is equal to: 0001 1011 again? y [9 BITS] is 511 in decimal notation again? y Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started