Problem 1: Write a program that will take command-line arguments from the user and perform the operations as shown in the examples: ./cmdline “hello ” + “World ” + “Good Times” hello World Good Times...

I need help writing the code in the attached file.Thank you.


Problem 1: Write a program that will take command-line arguments from the user and perform the operations as shown in the examples: ./cmdline “hello ” + “World ” + “Good Times” hello World Good Times ./cmdline1 “Hello” – “el” Hlo ./cmdline1 “Hello” * 3 HelloHelloHello ./cmdline1 “Hello” + “you” - “loy” Helou ./cmdline1 “Hello” - “boot” + “ Eloy” Hello Eloy Requirements: 1. You must have an array that contains the final string to be printed. This string gets printed after all the other operations have been completed. a. There must be an array that contains the final variable. 2. You can use functions that check if the string to be removed is a substring; and returns the offset of the beginning of that string. 3. You will need to have a method to append strings to another string. All strings are added to the end. 4. Removing a substring will cause the other parts of the string to shift forwards to find the space. a. Only the first occurrence of the substring to be removed is considered. 5. You must also modularize your code. You must have functions to perform the operations required. 6. Strings operations can include the following: (addition, subtraction, and multiplication). 7. Multiplication must be performed first. 8. If a string does not contain the substring to be removed the resultant string is the first string. Requirements for submission: 1. Your completed code 2. Screen capture of the code running. Show at least two scenarios of your code working. All functions are available for use and there are no restrictions on the functions you can use. Example strncat, strcat, strstr etc. 1. Multiplication must be done first 1. If multiplication is not an operator on the command line; the order of operation is easiest if you work from left to right See below for possible command line entries and their results: 1. ./cmdline Hello – el * 3 Result would be: Hello  ( this is because there isn’t elelel in Hello ) 1. ./cmdline Hello – l * 2 Result would be: Heo 1. ./cmdline Hello – el + el Result would be: Hloel  (This is because we are working from left to right) 1. ./cmdline Hello + el - el Result would be: Hloel This is because the addition add the el at the end and the subtraction removes the first occurrence of el) 1. ./cmdline Hello * 2 + " World" Result would be: HelloHello World 1. ./cmdline Hello * 2 - " World" Result would be: HelloHello Problem 2: (Break down into manageable chunks [use functions]) Write a program that will take the the following command line arguments: ./cmdline2 -b 100 -e 200 -s 4 -f textfile.txt -m w Characteristics of the program: · Name of executable cmdline2 · -b represents the beginning number of a range · -e represents the end number of a range · -s represents the step size of the range · -f represent the file to read from or write to · -m represents the mode of operation (w)rite or (r)ead 1. The program will print to the screen, the range of numbers based on the above options. It will write that same output to the file textfile.txt. ./cmdline2 -b 100 -e 200 -s 4 -f textfile.txt -m w 100 104 108 112 116 120 124 128 … 188 192 196 200 2. The program will read the range of numbers placed into the file based on the command line parameters. a. It will also print those values to the screen. b. If the mode is r for read, ignore all other options except -f for the file name. ./cmdline2 -f textfile.txt -m r 100 104 108 112 116 120 124 128 … 188 192 196 200 3. If any options is missing the program does not run eg ./cmdline2 -b 100 -s 4 Range end value is missing please try again 4. If the step size does not produce at least 1 iteration of the loop, the program doesn’t run eg ./cmdline2 -b 100 -e 200 -s 200 Program can’t run step size doesn’t allow program to iterate once. Requirements for submission: 1. Your completed code 2. Screen capture of the code running. Show at least two scenarios of your code working. You can use any library functions you require. You must also modularize your code; don’t put all of your logic in main.
Apr 06, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here