Question: Write Code in C, please read carefullyy! Part 1 Create Code6_xxxxxxxxxx.c. This program will be used to exercise the library functions that you will create
Write Code in C, please read carefullyy!
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 Code6_xxxxxxxxxx.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. Each menu option/case statement will call the library function and simply print the output array with printf() and %s no for loops in the menu. Part 2 Remove the code for PrintBinary() from MyLib.c. Eliminate PrintBinary() from MyLib.c and MyLib.h. Add a parameter to ConvertDecimalToBinary() to return the converted number in an array called OutputArray. This function is your first item on your new menu in Code6_xxxxxxxxxx.c. Add a call to ConvertDecimalToBinary() in Code6_xxxxxxxxxx.c. case 1 should call ConvertDecimalToBinary() and then Code6_xxxxxxx.c should print the returned output that is in OutputArray. Part 3 Create a new function called SentenceCleanup()in MyLib.c. Be sure to add the prototype to your MyLib.h. This function will have one parameter that is an array that contains the output from this function. This function will prompt the user for at least two sentences separated by one of 3 delimiters ?!. case 2 in your menu in Code6_xxxxxxxxxx.c will call SentenceCleanup() and then print the output. Here's what it looks like when executed. The input sentences are capitalized and 2 spaces are put in between each sentence and the original punctuation is retained. Enter at least two sentences separated by one of these delimiters - .!? - (max of 500 characters total) hello there!how are you? i am fine.
Hello there! How are you? I am fine. Here is the structure of the function. Please follow this outline. This is necessary to exercise various string library functions. void SentenceCleanup(char OutputArray[]) { Put your variables Prompt for sentences using fgets Store a copy of the input array before running strtok() Call strtok() the first time while using strtok() { Get the punctuation mark from the copy of the sentence Remove the sentence from the copy of the input string Throw out the spaces between sentences using a do-while loop Uppercase the first letter of the sentence Put the sentence and its punctuation into the final output } Copy the final output into the output array being returned } Part 4 Create a new function called SKUConverter()in MyLib.c. Be sure to add the prototype to your MyLib.h. This function will have one parameter that is an array that contains the output from this function. This function will prompt the user for a dashed SKU and will return the full SKU to Code6_xxxxxxxxxx.c to be printed. case 3 in your menu in Code6_xxxxxxxxxx.c will call SKUConverter() and then print the output. void SKUConverter(char OutputArray[]) { Put your variables here Prompt the user for a dashed SKU If the entered dashed SKU is greater than 9 character, Then print "The entered dashed SKU is not valid" and return If the first character of the input dashed SKU is not a digit (use isdigit()) or If the final character of the input dashed SKU is not a digit (use isdigit()) Then print "Dash must be between two numbers" and return. Use a for loop to check to see if each character of the input is a number and to find the dash in the input SKU. Set up a counter to count the number of dashes If you find a non digit/non dash, Then print "Input SKU can only contain numbers and one dash" and return If dash counter is 0 and the length of the input is 7, Then copy the input array into the output array and return. Else if the dash counter is 0, Then print "Input SKU must contain a dash" and return Else if the dash counter is greater than 1, Then print "Input SKU can only contain one dash" and return Save the input array into a new variable (LeftSide). Find the dash in LeftSide and replace it with a null terminator. Add 1 to the pointer to the dash and use that to copy the array after the dash into a new variable (RightSide). Use a for loop to right pad LeftSide with enough zeros to make LeftSide exactly 3 characters long. Copy LeftSide into a variable called FinalSKU. Use a for loop to left pad RightSide with enough zeros to make RightSide exactly 4 characters long. Concatenate FinalSKU with RightSide. Copy FinalSKU into your OutputArray. Retur
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
