CS300Fall19_Assignment2 CS 300 Data Structures Assignment-2 October 21, 2019 1 Due Date: October 30th XXXXXXXXXX:50pm (Wednesday) Develop an Expression Calculator using Stacks In this assignment, you...

1 answer below »
I upload the file


CS300Fall19_Assignment2 CS 300 Data Structures Assignment-2 October 21, 2019 1 Due Date: October 30th 2019 11:50pm (Wednesday) Develop an Expression Calculator using Stacks In this assignment, you are going to develop an expression calculator which accepts integer operands like 1, 2, 4959, -2 as well as integer operators including +, -, *, /, and %. Here are the functional requirements of the program: • The program inputs operands and operators from console • If the input is an integer, the calculator pushes that integer onto the stack • If the input is a valid operator, the program pops two integers off the stack, performs the requested operation, and pushes the result back onto the stack. • If the user enters the symbol <, the="" program="" prints="" the="" entire="" content="" of="" the="" stack="" •="" if="" the="" user="" enters="" the="" symbol="" ^,="" the="" program="" pops="" the="" top="" element="" off="" the="" stack="" and="" prints="" that="" element="" only="" •="" if="" the="" user="" enters="" the="" symbol="" \="" the="" program="" terminates="" •="" if="" the="" user="" enters="" an="" invalid="" input="" like="" 2.5="" or="" !="" or="" anything="" else="" that="" is="" not="" defined="" in="" our="" calculator,="" the="" program="" should="" prompt="" the="" user="" with="" an="" error="" message="" and="" keep="" running="" the="" program="" •="" if="" there="" are="" not="" enough="" operands="" to="" perform="" the="" operation,="" the="" program="" should="" prompt="" the="" user="" with="" an="" error="" message="" and="" should="" not="" stop="" the="" program.="" here="" are="" the="" requirements="" for="" stack="" implementation:="" •="" name="" stack="" implementation="" as="" linkedstack="" •="" use="" linked="" list="" data="" structure="" to="" implement="" stack="" •="" don’t="" reuse="" linkedlist="" header="" file="" we="" have="" created="" before.="" instead="" make="" a="" new="" linked="" list="" structure="" in="" linkedstack="" implementation="" •="" make="" stack="" implementation="" generic="" •="" make="" sure="" linkedstack="" extends="" stackadt="" (we="" have="" used="" in="" lab)="" and="" provide="" implementation="" for="" all="" abstract="" functions="" given="" in="" stackadt="" using="" linked="" list="" data="" structure.="" sample="" run-1:="" enter="" the="" expression:="">< 3="">< 2="" 6="">< +="">< *="">< ^="">< \=""><><3><6, 2,="" 3=""><8, 3=""><24> 24<> Result: 24 CS 300 Data Structures Assignment-2 October 21, 2019 2 Sample Run-2: < 2="" 6="" test="">< +="">< *="">< ^="">< \=""><> invalid input<6, 2=""><8> missing operands<8> 8<> Result: 8 HOW TO SUBMIT You are supposed to submit your source files (.cpp and .h files) as a single zip file via CANVAS and codepost. Please use the following file format while naming the zip file: LastNameFirstnameX_Y.zip where LastNameFirstname is your last name with the first letter in capital, followed by your first name with the first letter in capital; the X is the course code; the Y is the assignment #. (ex: SerceFatmaCS300_3.zip) HOW TO EVALUATE: The following rubric describes how your work will be evaluated. Correctness (90 points) • [90] Program is correct in object oriented design and function; meets specification • [75] Program output is correct but elements of specification missing, e.g. variable/method declarations. • [45] Part of the specification has been implemented, e.g. one out of two required • subprograms. • [20] Program has elements of correct code but does not assemble/compile. Readability (10 points) • [10] Programmer name and assignment present. Sufficient comments to illustrate program logic. Well-chosen identifiers. • [7] Programmer name present, most sections have comments. Fair choice of identifiers • [5] Few comments, non-meaningful identifiers • [0] No programmer name. No comments. Poor identifiers
Answered Same DayOct 29, 2021

Answer To: CS300Fall19_Assignment2 CS 300 Data Structures Assignment-2 October 21, 2019 1 Due Date: October...

Neha answered on Oct 31 2021
147 Votes
#include
#include
#include
using namespace std;
// This Function is to
solve the Postfix expression and return output
int EvaluatePostfix(string expression);
// This Function is to perform an operation and return output.
int PerformOperation(char operation, int operand1, int operand2);
// This Function is to verify whether a character is an operator symbol or not.
bool IsOperator(char C);
// This function is to check if the character is number or not.
bool IsNumericDigit(char C);
//Main function where compiler will point
int main()
{
    string expression;
    cout<<"Enter Postfix Expression \n";
    getline(cin,expression);
    int result = EvaluatePostfix(expression);
    cout<<"Output = "<}
// This Function is to evaluate Postfix expression and return output
int EvaluatePostfix(string expression)
{
    // Declare a Stack
    stack S;
    for(int i = 0;i< expression.length();i++) {
        // Start scanning...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here