Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you give me the actual c + + code using this as a starter code? #include #include #include using namespace std; const string ID

Can you give me the actual c++ code using this as a starter code?
#include
#include
#include
using namespace std;
const string ID = "Stellar Carroll - CS 1337- Lab 31
";
int main()
{
short HammingChar;
uint bit1, bit2, bit4, bit8, offendingBit;
char ch;
// output ID Line
cout ID;
// read an unknown # of short ints, each representing a Hamming character
while (cin >> HammingChar)
{
offendingBit =0;
// Use the formula to calculate parity bit 1
bit1=(getBit(HammingChar,11-3)+
getBit(HammingChar,11-5)+
getBit(HammingChar,11-7)+
getBit(HammingChar,11-9)+
getBit(HammingChar,11-11))%2;
// Use the formulas to calculate parity bits 2,4, and 8
bit2=(getBit(HammingChar,11-3)+
getBit(HammingChar,11-6)+
getBit(HammingChar,11-7)+
getBit(HammingChar,11-10)+
getBit(HammingChar,11-11))%2;
bit4=(getBit(HammingChar,11-5)+
getBit(HammingChar,11-6)+
getBit(HammingChar,11-7))%2;
bit8=(getBit(HammingChar,11-9)+
getBit(HammingChar,11-10)+
getBit(HammingChar,11-11))%2;
// Now compare the calculated bit 1 to the value from the HammingChar
if (bit1!= getBit(HammingChar,11-1))
offendingBit +=1;
// do similarly for bits 2,4, and 8
if (bit2!= getBit(HammingChar,11-1))
offendingBit +=1;
if (bit4!= getBit(HammingChar,11-1))
offendingBit +=1;
if (bit8!= getBit(HammingChar,11-1))
offendingBit +=1;
cout "Debug: offendingBit =" offendingBit endl;
// if offendingBit !=0 then
// intvert (11- offendingBit)
// Build ch from HammingChar
ch = setBit(ch,7,0); //initialize the high bit of ch to 0
// cout ch;
}
return 0;
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago