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

evaluate this expression in C++ 9 - 6 * ( 2 + 8 / 4 ) - 1 + 3 * 7 % 5. it divide

ID: 3561815 • Letter: E

Question

evaluate this expression in C++ 9 - 6 * ( 2 + 8 / 4 ) - 1 + 3 * 7 % 5. it divides the problem into two distinct parts -- a scanning part (tokenize) to understand the character text of the expression and break it up into individual values and operators (i.e. tokens); and an evaluation part that will understand how all the tokens combine to compute a value.

please fill the first part tokenize.cpp

// Tokenize Implementation file
// This is a very crude tokenizer for use in an expression parser.
// At the moment, it is simply a collection of functions that
// that will later be encapsulated into an object-oriented class.
// It has only a very rudimentary behavior at this time.
//
// This tokenizer will begin with a character string representing
// an expression, and will identify and return tokens as requested.
// These tokens may be separated by space characters within the string.
// It has the following limitations:
// --- only integers and operators are supported (no names)
// --- all tokens must be exactly one character, including integers

// The standard C library has some useful functions for us
#include
#include

// nextToken
// Identifies the next non-space character in the given string
// Parameters:
// expr (input string) expression to examine
// pos (modified integer) position to begin looking at
// token (output char)       the actual non-space character
// Post-condition: token == expr[pos] && token is not a space
void nextToken( const char expr[], int &pos, char &token )
{

}

// advance
// advance to after the end of the next token (as defined above)
// Parameters:
// expr (input string) expression to examine
// pos (modified integer) position to consider
// Pre-condition:
// There is at least one token remaining; if not,
// this will stop at the end of the string
// NOTE: If expr[pos] is non-space, this will advance exactly one position
//
// advance to the following token in the string (if any)
void advance( const char expr[], int &pos )
{


}

// identify whether token is an integer or operator
// Parameter:       character to examine
// Returns:       boolean, depending on the question
bool isInteger( char c )
{
return isdigit( c );
}

// identify the value of an integer token
// Parameter:       character to examine
// Returns:       the numeric value of the digit
// Pre-condition: the character actually is indeed a numeric digit
int integerValue( char c )
{
return c - '0';
}

and write a evaluate.cpp

// Simple Expression Evaluation Implementation file
// This describes the functionality for evaluating very simple
// arithmetic expressions. Given a string consisting of operators
// and operands, it will evaluate that expression and return its value.
//
// The expressions may consist of the following:
// -- single-digit integer values
// -- simple arithmetic operators ( +, -, *, /, % )
// -- matched parentheses for grouping

// This implementation consists of a set of mutually-recursive
// functions. which will track the structure of the expression.
//
// A sum expression is the sum or difference of one or more products.
// A product expression is the product or quotient of one or more factors.
// A factor may be a number or a parenthesized sum expression.

#include "tokenize.h"

please complete those 2 files

Explanation / Answer

//please refer http://www2.lawrence.edu/fast/GREGGJ/CMSC270/Infix.html for details