Question: Java Programming: Below is the ProgramNode extends Node.java file. There is an error in the 3rd curly brace after the system.out.println(): so please fix that

Java Programming: Below is the ProgramNode extends Node.java file. There is an error in the 3rd curly brace after the system.out.println(): so please fix that error. Attached is the rubric that is circled in black all the components the ProgramNode extends Node.java file must have. Attached is the output it must produce. Make sure to show the full code without any errors.

ProgramNode.java

package mypack;

import java.util.HashMap;

public abstract class ProgramNode extends Node { private HashMap functions;

public ProgramNode() { functions = new HashMap(); } public void addFunction(String name, FunctionNode function) { functions.put(name, function); }

public FunctionNode getFunction(String name) { return functions.get(name); }

public void printFunctions() { for (String name : functions.keySet()) { System.out.println(name); functions.get(name).print(); System.out.println(); } } }

FunctionNode myFunction = new FunctionNode("myFunction"); myFunction.addParameter(new VariableNode("x")); myFunction.addParameter(new VariableNode("y")); myFunction.addVariable(new VariableNode("z")); myFunction.addConstant(new ConstantNode("PI", 3.14159)); myFunction.addStatement(new AssignmentNode("z", new BinaryOpNode("+", new VariableNode("x"), new VariableNode("y")))); myFunction.addStatement(new ReturnNode(new VariableNode("z")));

program.addFunction("myFunction", myFunction);

HashMap functionMap = new HashMap (); for (FunctionNode functionNode: functionNodes) { functionMap.put(functionNode.getName(), functionNode); } return new ProgramNode(functionMap); }

}

Java Programming: Below is the ProgramNode extends Node.java file. There is an

error in the 3rd curly brace after the system.out.println(): so please fix

Output:- 123456789101112myFunctionParameters:xyVariables:zConstants:-PI:3.14159Statements:-zx+y-returnz Output:- 123456789101112myFunctionParameters:xyVariables:zConstants:-PI:3.14159Statements:-zx+y-returnz

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!