Question: The Template of the code is given below this. Using the coding outline template exactly shown and given , write the code using the rules
The Template of the code is given below this. Using the coding outline template exactly shown and given write the code using the rules and test cases from the photos given all below:
# The user is prompted to enter a pseudo arithmetic command. The input must be verified to be grammatically correct.
The string and character type library cannot be used under any circumstances. You are encouraged to develop your own functions to perform any similar operations that are needed. This includes strlen strcpy strcmp islower
No changes to the code in main. Your code must be placed in functions. Additional functions are encouraged
As well as the guidelines in the photos given while also confirming the test cases:
do not include any additional libraries
#include
do not change these constants
#define MAXLINE
#define MAXOPER
named constants and strings
enum operations NOOP ADD, MUL, DIV, POW;
const char operationstrInvalid;
function prototypes
int processinputconst char input char opleft, char opright;
void calcoutputconst char opl int op const char opr char result;
do not change any code in main. We are grading based on the format
of the output as given in the printfs in main.
int main
char inputlineMAXLINE;
char leftoperandMAXOPER;
char rightoperandMAXOPER;
char answerMAXOPER;
int operator;
printf
PP: Arithmetic on GF with using letters
;
printfCommands:
tabcbbc
tturtlefrog
ttigerone";
printftOperands are no more than letters and no spaces
;
printftCtrld to quit
;
printf;
each call to fgets collects one line of input and stores in inputline
BEWARE: fgets includes the endofline character
in inputline
while fgetsinputline, sizeof inputline, stdin NULL
clear for next round
leftoperand rightoperand answer;
check for valid grammar
operator processinputinputline, leftoperand, rightoperand;
if operator ADD operator MUL
operator DIV operator POW
print parsed input
printfs leftoperand;
printfs operationstroperator;
printfs rightoperand;
perform pseudo arithmetic
calcoutputleftoperand, operator, rightoperand, answer;
print result
printfs
answer;
else
printf# s inputline;
printf;
printf
Goodbye
;
return ;
Parse input of the form SOS where S is a string ie the operand
and O ie the operator is a character.
A string S must consist of up to valid symbols az and AU
The operator O must be one character from:
Any other characters found in the input, including spaces, are
grammatically incorrect and invalidate the input.
There must be NO spaces anywhere in the input, including between
either SO OS or leading or trailing spaces.
Input: The input string is collected using fgets. Recall the endofline
character is included in the input string and marks the end of
the input. This string must not be changed.
Output: There are three outputs from this function.
The return value is one of NOOP, ADD, MUL, DIV, POW which are
named constants. If the input is invalid for any reason
then the output must be NOOP. Otherwise the return value
corresponds to operand O
If the input is grammatically correct, then two strings are also
returned, one for each of the left and right operands. If the input
in invalid the two output strings are undefined.
int processinputconst char input char opleft, char opright
REPLACE the following with your code
opleftA;
opleft;
oprightA;
opright;
return ADD;
Pseudo mathematical opertions on the two operands work as follows.
Each character is converted to an integer in the range where a is
b is c is z is The operation is then performed using
math on a finite field with no carries.
If the two input strings are not the same length, then each output character
beyond the length of the shorter string should be a copy of the character
from the longer string but with the opposite case.
Input: The two operand strings and the operator are assumed to be valid and
are verified as valid in the parseinput function
Output: The final string generated by the above rules is stored in the
output string named result. The input strings must not be
changed.
void calcoutputconst char lop int op const char rop char result
REPLACE the following with your code
result;
result;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
