I need help in how to call a file in java: (file names are sample_input1.txt, sample_input2.txt, sample_input3.txt) //These are all the imports you are allowed,
I need help in how to call a file in java: (file names are sample_input1.txt, sample_input2.txt, sample_input3.txt)
//These are all the imports you are allowed, don't add any more! import java.util.Scanner; import java.io.File; import java.io.IOException;
class SimpleCompiler { public static Node fileToQueue(String filename) throws IOException { //given a file name, open that file in a scanner and create a queue of nodes //the head of the queue of nodes should be the start of the queue //the values in the nodes should be the strings read in each time you call //next() on the scanner return null; } public Node compile(Node input, int numSymbols) { //Given an input queue of symbols, process the number of symbols //specified (numSymbols) and update the callStack and symbols //variables appropriately to reflect the state of the "SimpleCompiler" //(see below the "do not edit" line for these variables). //Return the remaining queue items. //For example, if input is the head of a linked list 3 -> 2 -> + //and numSymbols=2, you would push 3 and push 2, then return the linked //list with just the + node remaining. return null; } public static void testThisCode() { //edit this as much as you want, if you use main without any arguments, //this is the method that will be run instead of the program System.out.println("You need to put test code in testThisCode() to run SimpleCompiler with no parameters."); } //--------------------DON'T EDIT BELOW THIS LINE-------------------- //----------------------EXCEPT TO ADD JAVADOCS---------------------- //don't edit these... public static final String[] INT_OPS = {"+","-","*","/"}; public static final String[] ASSIGN_OPS = {"=","+=","-=","*=","/="}; //or these... public CallStack
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance