Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Kindly share your solution in a presentable manner and also screenshot of output Please its my project its my posting 3rd time i need presentation

Kindly share your solution in a presentable manner and also screenshot of output

Please its my project its my posting 3rd time i need presentation mode with screenshot dont copy paste

CSS 342 extra coding.

This is a three part project:

Part one build a program that:

Prompts the user for a string of user input .

Treat that string as a mathematical expression in an infix form.

Convert the string into a series of tokens where each token is an operator, or a value delimited by whitespace , operator, or

Part two

Convert to postfix and print out the results. ( or print out an error if badly formed)

Part Three further.

Do the math to evaluate the expression when all operands are values ( not variables)

Each part will add up to 10 points to your coding grade in class.

For this project the operators you will support are:

Plus +

Minus

Times *

Divide /

Modula %

When I test the program I would expect to see something like this: ( Bold is what I enter on the command line)

Input an expression: A+ B * 31

Tokens: A + B * 31

Postfix: A B + 31 *

Value: Cannot be calculated

Input and Expression: 3+4*12

Tokens: 3 + 4 * 12

Postfix: 3 4 12* +

Value: 51

If the input expression is invalid, print out that fact. Use exceptions to catch any error conditions.

(Note put a space between each Token for clarity)

A few things that we have not talked about ( or talked about in class today)

How do you look at a string and know what the operands vs operators. IE if the input string is:

A+FRED+23*13-GG OR A + FRED +23* -GG

How do you identify that the tokens are A, FRED, 23, * etc. and which tokens are operands vs operators?

The easiest way is with a stack.

Put the first character on the stack.

Keep putting characters on until you see an unpend char ( a space) OR an operator or a

Pop the chars off the first stack onto a second

Pop the chars off the second stack ( now they are in proper order)

Pass the token to your infx to postgix code.

If you have an operator. Send that

Repeat until no more characters.

50% of grade will be does it work with simple test case

30% of grade. Does it work in all test cases

10% Format. Indentation readability

10% comments.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions