Question: I need help with a Java program. I have already started and created a frame with a textfield, a start button and some labels. Now

I need help with a Java program. I have already started and created a frame with a textfield, a start button and some labels. Now I struggle with the content. The task is, that one should be able to enter terms into the textfield that have to be calculated. Now you cant just enter the terms, but you have the variables a,b,c,d,e which equal real numbers. And the operators ~, &, ?. They are defined like this: ~ a b c equals a+bc, so ~ 2 3 4=1. &abcde equals a+b+cde, so & 1 2 3 4 5 = 3 . ? a b c d equals a+b c+d, so ? 2 3 4 5 = 6. If you have a term with several operators, it looks like this: ~ 2 3 ~ 2 5 7 and shall be calculated like this 2+3(2+57)=9. Now you shall also be able to save the term, for example ~ 2 3 ~ 2 5 7 in a tree (see image). So if you enter a term into the textfield and click the start button, it shall be calculated. That has to be done with a recursive method public double eval(). Because the entered term is a String we have to break it down into an array of strings with a java method. The program has to work with the implemented tree structure, we are not allowed to use collection classes or sets. The program has a class programm with a main method, this has to be the only main method in the program. All other classes have to be structured, so that they make sense and all classes have to include the method toString. On the image you can see my GUI, in the top right corner you should see the calculation after clicking the start button and in the middle you should see the tree. If the entered term is incorrect there should be an error message in the top right corner. Do you think you could do something like this?class TreeObjekt{ private TreeObjekt parent = 0; private TreeObjekt leftChild = 0; private TreeObjekt rightSiblings = 0; private T data; ... }t leftChild is a head reference to an easy chained list and rightChild is like the "next" reference in an easy chained list the tree should be implemented like this:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!