Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

examples code below in part 2 below MyLib.h and makefile Coding Assignment 6 Par

ID: 3738361 • Letter: E

Question

examples



code below in part 2

below MyLib.h and makefile





Coding Assignment 6 Part 1 Create Code6 xxxxxxxxxx.c. This program will be used to exercise the library functions that you will create as part of this assignment. This program will display a menu where each menu item will be one of your library functions which will reside in MyLib.c 1. Convert Decimal to Binary 2. Sentence Cleanup 3. SKU Converter Enter menu choice Code 6 xxxxxxxxx. c will not contain any of the code for these functions-they will only be called and the output will be printed. Use a switch statement to create the menu. Remember to use a default statement in case a menu choice is entered that is not valid.

Explanation / Answer

void ConvertDecimalToBinary(int* output){

output = BitArray;

}

void SentenceCleanUp(char* output){

string s,l;

cout<<"Give the sentence(You can only use ?!. as delimeter):"<<endl;

gets(l);

int i=0,c=0;

while(i<l.length()){

if(c==0){

s+=(toupper(l[i]));

c=1;

}

else{

if(l[i]=='?'||l[i]=='!'||l[i]=='.'){

s+=l[i]+" ";

c=0;

continue;

i++;

}

else

s+=l[i];

}

i++;

}

output = new char[s.length()];

for(int i=0;i<s.length();i++){

output[i]=s[i];

}

}

void SKUConverter(char* output){

cout<<"Put your variable here:"<<endl;

string s,f,l;

scanf("%s",s);

int c=0;

if(s.length()==7){

for(int i=0;i<7;i++){

if(s[i]=='-')

return;

}

output=new char[7];

for(int i=0;i<7;i++){

output[i]=s[i];

}

return;

}

for(int i=0;i<s.length();i++){

if(s[i]=='-'){

c=1;

continue;

}

if(c==0){

f+=s[i];

}

else{

l+=s[i];

}

}

if(l.length()==0||f.length()==0)

return;

else{

output=new char[8];

for(int i=0;i<8;i++){

output[i]='0';

}

for(int i=0;i<f.length();i++){

output[i]=f[i];

}

for(int i=8-l.length();i<8;i++){

output[i]=l[i];

}

}

}