Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I wantto make a java program that read from a fileseveral postfix lines (the text file picture attached)and write the output in another text file.

I wantto make a java program that read from a fileseveral postfix lines (the text file picture attached)and write the output in another text file. (read from a file and write in another text file)The input is postfix and the output should be variables.The complete question and the input file are as shown bellow.

image text in transcribedimage text in transcribed
inputfile.txt - Notepad File Edit Format View Help AB+C- ABC+- AB -C+DEF-+^ ABCDE-+^*EF*- ABC+*CBA-+* ABC+/CBA*+ AB - *CBA+ -* ABC -/ BA-+/ ABC+^CBA -+* ABO+/CBA+-/605.202.31 Data Structures La b1 - Stack Problem Assume a machine that has a single register and six instructions. LD A Places the o-erand A into the re- ister. ST A Places the content of the re-ister into the variable A. AD A Adds the content of the variable A from the rec ister. SB A Subtracts the contents of the variable A from the re- ister. ML A Multi-lies the contents of the re-ister b the variable A. DV A Divides the contents of the register by the variable A. Write a program that accepts a postfix expression containing single letter operands and the operators +, -, *, and / and prints a sequence of instructions to evaluate the expression and leave the result in the register. Use variables of the form TEMP as temporary variables. For example, using the postfix expression ABC*+DE-/ should print the following: LD B ML C ST TEMP1 LD A AD TEMP1 ST TEMP2 LD D SB E ST TEMP3 LD TEMP2 DV TEMP3 ST TEMP4 Keep in mind that you are NOT evaluating the postfix expression, you are generating the machine language instructions that would perform the evaluation if actually executed. In your analysis, be sure to discuss the implementation you choose and why, why a stack makes sense. Consider a recursive solution (you do not need to implement recursion) and compare it to your iterative solution. Is one better than the other? Why? Tell us what you learned and what you would do differently. Be sure to review the programming assignment guidelines, including the formatting requirements for the analysis. You may not use library functions. You must write your own code, in particular you must write the stack code. Be sure to include the stack source code in your submission. You must read and write from named files

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_2

Step: 3

blur-text-image_3

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions