Cash-back offer from May 7th to 12th, 2024: Get a flat 10% cash-back credited to your account for a minimum transaction of $50.Post Your Questions Today!

Question DetailsNormal
$ 18.00

Programming Assignment 5 Expression Evaluator | Complete Solution

Question posted by
Online Tutor Profile
request

Computer Science I – Programming Assignment 5
Expression Evaluator
Problem:
Write a program that reads an infix or postfix expression from an input file,
evaluates the expression and outputs the result.
Objectives:
The objective of this assignment is for students to demonstrate a working
knowledge of:
Stack implementation using a linked list
Evaluation of postfix notation
Evaluation of infix notation
Requirements:
When your program is run, it should read input from an input file one line at a time.
Each line will begin with the number 1 or 2 followed by a space. 1 indicates that the
expression which follows, is in infix notation; while 2 indicates that the expression
which follows is in post fix notation. Your program should read and process each
line of input, outputting the postfix notation and the value that the expression
evaluates to. Output should be written to a file called output.txt the output file will
consist of all of the calculated output, each written on a new line in the file. Your
program should continue to read and process data from the input file, until a line
beginning with the number 0 is encountered.
The name of your input file will be passed as an argument to main so it should not
be hardcoded in your program
Required functions:
Your program should include the following functions
For the stack implemented as a linked list
1. stack* initStack() : this creates and initializes the values of the stack
implemented as a linked list
2. stack* push(stack *s, char c): takes a stack pointer as a parameter and
adds the character parameter to the top of the stack and returns a pointer to
the updated stack
3. char pop(stack *s): pops the stack and returns the character popped out
4. char peek (stack *s): looks at the top value on the stack and returns the
value seen
5. int IsEmpty(stack *s)checks to see if the stack is empty returning 0 for false
and 1 for true.
6. void evaluatePostfix(char *) which takes a postfix expression as a char
array and an integer indicating the length of the array. The function should:
- write the expression to the output file
- evaluate the expression using a stack
- and write the integer value obtained to the output file as shown in the
sample output
7. void evaluateInfix(char *) which takes an infix expression,
- converts it to the postfix form
- and then evaluates the expression.
- Both the postfix notation and the value it evaluates to, are written to the
output file (as shown in the sample output).
Note that these are the required functions but you are allowed to create additional
helping functions if you wish.
What do you submit?
For this assignment you are required to submit your source code as a single .c file
called ExpEvaluator.c. All submissions are to be made via Webcourses by the
deadline. Email Assignments will not be accepted. There will be NO EXTENSION
FOR THIS ASSIGNMENT. You may choose to submit up to 24 hours late, with
15% grade penalty.
Note: If your program does not compile on Eustis you will receive a maximum score
of 40 if your code has all of the functions. If your code does not compile and there
are missing functions, then you will receive a grade lower than 40.
Expectations for code testing:
Your code will be tested on Eustis. The test file used by the TA will not be the one
given in the sample input. However, it will match the specifications given in the
assignment. For example there may be more or less lines of input but the file
format will be the same and the data will end with a 0.
Sample input.txt
1 (5 + 4)
2 3 4 +
1 2 * 2 /(1 + 3)
0
Sample output file from running code
5 4 + = 9
3 4 + = 7
2 2 * 1 3 + / = 1
Sample2 input.txt
2 7 5 - 2 +
1 3 * (5 – 2 )
1 5/1 + 3
0
Sample output2 file from running code
7 5 - 2 + = 4
3 5 2 - * = 9
5 1 / 3 + = 8
Grading Rubric
Comments and formatting of code……………..…5
Stack methods……………………………………………40
Appropriate naming of variables ……………….. 5
Correct file I/O………………………………………... 5
Correct evaluation of Postfix……………………….10
Correct Evaluation of Infix…………………………..10
Correct output format…………………………………5
Total ………………………………………………………80

Available Answer
$ 18.00

[Solved] Programming Assignment 5 Expression Evaluator | Complete Solution

  • This solution is not purchased yet.
  • Submitted On 27 Mar, 2016 08:56:31
Answer posted by
Online Tutor Profile
solution
#include #include #include #include typedef struct ListNode{ char opr; struct ListNode* next; }Node; typedef struct{ Node* top; }stack; FILE* fpIn = NULL; FILE* fpOut = NULL...
Buy now to view the complete solution
Other Similar Questions
User Profile
4.0St...

CSIS 312 LU Programming Assignments 1, 2, 3, 4, 5, 6, 7, 8

All Solutions for entire class Included in one order. Programming Assignments 1-8 CSIS312 (BMIS 312) LU ...
User Profile
Exper...

MAT540 Week 8 Assignment 1. Linear Programming Case Study | Complete Solution

Let’s assume they need to order, X1 units of the adult Open Trail, X2 units of the adult Cityscape, X3 units of the girl's Sea Sprite and X4 units of the boy's Trail Blazer to maximize the profit. Then from the given in...
User Profile
smart...

CSCI 114 Programming Fundamentals II | Lab 4 Wallet | Solution

This Tutorial is rated A+ previously,if you have any questions regarding this tutorial then you can contact me....
User Profile
termp...

Object-oriented Programming (OOP) / Event-Driven Programming (EDP) versus Procedural Programming

Object-oriented Programming (OOP)Object-oriented Programming (OOP)Object-oriented Programming (OOP) ...
User Profile
termp...

IT244M2Part1A.docx Security with Python Programming Purdue University Global Python S

IT244M2Part1A.docx Security with Python Programming Purdue University Global Python Security The python coding language is a great tool for data security. Since python is open source there are a wide variety of librarie...

The benefits of buying study notes from CourseMerits

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35