Node, StackArray, StackRef and Stack interface classes PROVIDED BELOW to create code that reads input from the sample Data File PROVIDED to solve PLEASE READ DIRECTIONs VERY CAREFULLY please answer in full here and thanks for your help Data File 2 3 4 + + 12 6 / 4 * 4 + 2 2 3 3 * * * 7 5 / 5 + 17 - 4 3 - 5 6 + 4 * - 1 1 + 3 * 4 - 10 ^ public class Node { private T data; private Node<
USE the Node, StackArray, StackRef and Stack interface classes PROVIDED BELOW to create code that reads input from the sample Data File PROVIDED to solve
PLEASE READ DIRECTIONs VERY CAREFULLY
please answer in full here and thanks for your help
Data File
2 3 4 + +
12 6 / 4 * 4 +
2 2 3 3 * * *
7 5 / 5 + 17 -
4 3 - 5 6 + 4 * -
1 1 + 3 * 4 - 10 ^
public class Node <T>
{
private T data;
private Node<T> next;
public Node(T data, Node<T> next)
{
this.data = data;
this.next = next;
}
public T getData()
{
return data;
}
public Node<T> getNext()
{
return next;
}
}
import java.util.Stack;
public class StackArray<T> implements Stack<T> {
private T [] elements;
private int top;
private int size;
public StackArray (int size)
{
elements = (T[]) new Object[size];
top = -1;
this.size = size;
}
public boolean empty()
{
return top == -1;
}
public boolean full()
{
return top == size - 1;
}
public boolean push(T el)
{
if (full())
return false;
else
{
top++;
elements[top] = el;
return true;
}
}
public T pop()
{
T el = elements[top];
top--;
return el;
}
}
// Generic Stack Reference Implementation
public class StackRef<T> implements Stack<T>
{
private Node<T> top;
public StackRef (int size)
{
top = null;
}
public StackRef()
{
top = null;
}
public boolean empty()
{
return top == null;
}
public boolean full()
{
return false;
}
public boolean push(T el)
{
Node<T> node = new Node<>(el, top);
top = node;
return true;
}
public T pop()
{
if (empty())
return null;
T el = top.getData();
top = top.getNext();
return el;
}
}
// Generic Stack Interface
public interface Stack<T>
{
public boolean empty();
public boolean full();
public boolean push(T el);
public T pop();
}
import java.util.Scanner;
import java.util.Stack;
import java.util.Set;
import java.io.*;
import java.util.*;
public class RPN {
private static Stack<String> stack;
private static FileReader file;
private static Scanner in;
private static Set<String> operators;
}
![Program Output
Line: 2 3 4 + +
Result: 9
Line: 12 6 / 4 * 4 +
Result: 12
Line: 2 2 3 3 ***
Result: 36
Line: 75 / 5 + 17 -
Result: -11
Line: 4 3 - 5 6 + 4 *
Result: -43
Line: 1 1 + 3 * 4 - 10 ^
Result: 1024](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F92a10496-2174-49e0-bdb3-b03a709ba0d7%2F2da45751-f323-4fd3-bc2b-5fb78876c6cd%2Fnbchgk_processed.png&w=3840&q=75)
![In class we developed code for a Generic Stack. The classes were Node, StackArray, StackRefas wel
as the Stack interface. All were generic and use the <T>type parameter. We also developed the
algorithm (logic) to process reverse polish notation (RPN) expressions, suchas 23 + or 234 +* 2*
The operators +, -, and * are will always returninteger values gives integer expressions. Your /and ^
operators should also return integer expressions. You are likely to use the Math.pow method to
implement the ^ operator. However, be aware that it returns a result of type double.
Use the Stack interface and the Node and StackRef classes in a new project called RPN. You will add
a client program to read the data file below which achieves the output as specified below. You will need
to determine a stack parameter <T> to use. Since you are reading a file (line by line), you will readeach
line as a String. You will need to break up that line into a series of tokens. The String split method is
an easyway to create anarray of String tokens. For example, after reading the line "12 6/4*4+"
split will produce anarray of 7 String elements (7 tokens). For each token you will need to determine
if it is an operator or an operand, and act according to your RPN processing algorithm. Todetermine if
the token is an operand, you may want to create a Set<String>of all possible operators, then use the
contains method to determine if the token is an operator. If you determine that the token is an operand
(integer), you will want to push it on the stack. Since the token is always a String, you can push the
operand as a String (on your Stack<String>) or convert it to an integer value using the
Integer.parseInt() method and push the operand as an int (on your Stack<Integer>). Whichever
Stack parameter <T>you use, you will need to convert the String-stored integer value to an int-
before pushing or after popping it off.
Create a project and demonstrate that you can process a file of RPN expressions. All lines in this sample
Data File are correct. You do not have to try to catch bad input in this lab.
Data File
234 ++
12 6/4 * 4 +
2233 **
75/5+ 17 -
43 -5 6+ 4 * -
11+ 3 * 4 - 10 ^](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F92a10496-2174-49e0-bdb3-b03a709ba0d7%2F2da45751-f323-4fd3-bc2b-5fb78876c6cd%2Fhutorhd_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
It is defined as a powerful general-purpose programming language. It is used to develop desktop and mobile
applications, big data processing, embedded systems.
A simple java program example :
class Simple
{
public static void main(String args[]){
System.out.println("Good Morning");
}
}
Data types of java are divided into two groups :
(i) Primitive data types : It includes byte, short, int, long, float, double, boolean and char.
(ii) Non-primitive data types : It includes strings, arrays and classes.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)