×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Create a Program to Implement Collaborating Plotterin C-Language Assignment Solution.

July 15, 2024
Dr. Jonathan Wright
Dr. Jonathan
🇯🇵 Japan
C
Dr. Jonathan Wright earned his PhD in Computer Science from Tokyo University in Tokyo, Japan. With 8 years of experience in the industry, he has completed over 800 C programming assignments with outstanding results. Dr. Wright's research focuses on distributed systems and cloud computing, and his wealth of knowledge in these areas allows him to deliver innovative and reliable solutions to programming tasks.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
When working on OCaml assignments, make use of pattern matching to simplify your code. It provides a clean and efficient way to handle different cases, especially for recursive functions and data structures like lists and trees. This can reduce complexity and improve readability.
News
Universities worldwide are seeing a surge in programming enrollment, as coding becomes an essential skill across disciplines. To meet growing academic pressures, more students are seeking online help for programming assignments and coursework.

Instructions

Objective

Write a program to implement collaborating plotterin C-language.

Requirements and Specifications

Lab 04: To demonstrate command of I/O

Problem Statement: Collaborating Plotter

You are asked to write a C homework coPlot.c that will cooperate with the end-user, accept keyboard input during execution, and output the results based on the user's commands. More precisely, your program will support the following "commands" typed-in by the end-user during runtime:

1> Bit operations:

Logic GateOperandsManipulation
bit_orbitwise OR of the two specified integers
bit_andbitwise AND of the two specified integers
bit_xorbitwise XOR of the two specified integers
bit_shift_left- shift the bits of the integer s k bits to the left
bit_shift_right- shift the bits of the integer s k bits to the right

2> String Operations:

reverse - reverse of the specified string

3> Termination:

exit - stop the execution of your program

When your program is started, it should ask the user for a command to run. Once the user types-in the command, your program should do the processing and print the results to the screen. This shall continue until the user types the exit command, at which point your program terminates.

Here is an example run:

• :~> ./coPlot >> Please enter a command to run. bit_or 15 25 31 >> Please enter a command to run. bit_and 15 25 9 >> Please enter a command to run. bit_xor 15 25 22 >> Please enter a command to run. reverse hello olleh >> Please enter a command to run. reverse CST_8234_Intro_to_C_Prog gorP_C_ot_ortnI_4328_TSC >> Please enter a command to run. exit Good Bye!

Useful Tips:

  • Use the function atoi, defined in stdlib.h, to convert string input from the user to an integer for the bitwise operations.
  • chars have numerical values in ASCII (for example 'a' has the numerical value 97, 'A' has value 65, and '0' has value 48 in ASCII). Additionally, sequential characters have sequential numerical values (for example, 'b' has value 98 and 'c' has value 99). Thus, to get the character forward from char c, you can just do c+1.

Submission Instructions

  • You must submit your source code (.c file) and makefile in the assigned submission folder on BRS section 010 (activities Assignments). We don’t need your entire project folder.
  • Your programs will be compiled with GCC and tested on WSL. Keep in mind that your assignment testing will be on fixed environment and therefore your applications is expected to run on that.

Marking Scheme

ItemPenalty
Coding correctness (functions’ structure) is substandard5 marks
Inappropriate and Inefficient Logic1 marks
Other specification violations2 marks
Defilements in regards to distribution of well-contained functions between files and makefile2 marks
Missed demonstration2 marks
Input validation is inacceptable5 marks
Total_Out of 20.

Source Code

#include #include #include #define TRUE 1 #define STR_LEN 255 /* Entry point of the program */ int main(int argc, char *argv[]) { int int1, int2; char command[STR_LEN]; char line[STR_LEN]; while (TRUE) { /* Get command */ printf(">> Please enter a command to run.\n"); fgets(line, STR_LEN, stdin); line[strlen(line) - 1] = '\0'; /* Break the command into tokens */ if (strcmp("exit", line) == 0) { /* Exit command executed */ break; } else if (sscanf(line, "%s %d %d", command, &int1, &int2) == 3) { /* If there are 3 tokens then it might be integer operations */ if (strcmp(command, "bit_or") == 0) printf("%d\n", int1 | int2); else if (strcmp(command, "bit_and") == 0) printf("%d\n", int1 & int2); else if (strcmp(command, "bit_xor") == 0) printf("%d\n", int1 ^ int2); else if (strcmp(command, "bit_shift_left") == 0) printf("%d\n", int1 << int2); else if (strcmp(command, "bit_shift_right") == 0) printf("%d\n", int1 >> int2); } else if (sscanf(line, "%s", command) == 1 && strcmp(command, "reverse") == 0) { /* Perform reverse, we start at the end of the line and stop before the word 'reverse'. The reason why we stop at index 7 is because 'reverse' has a length of 6 and add 1 to the space */ for (int1 = strlen(line) - 1; int1 >= 7; int1--) printf("%c", line[int1]); printf("\n"); } } printf("Good Bye!\n"); return 0; }

Similar Samples

Explore our C assignment sample to see how we tackle complex programming challenges with precision. Our expert solutions demonstrate clear, structured code and thorough explanations, ensuring you understand each concept. Whether you're grappling with loops, functions, or data structures, our sample will guide you through effective problem-solving techniques and best practices.