subject

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 callStack = new CallStack<>();
public LookUpBST symbols = new LookUpBST<>();

public static void main(String[] args) {
//this is not a testing main method, so don't edit this
//edit testThisCode() instead!

if(args. length == 0) {
testThisCode();
return;
}

if(args. length != 2 || !(args[1].equals("false") || args[1].equals("true"))) {
System. out. println("Usage: java SimpleCompiler [filename] [true|false]");
System. exit(0);
}

try {
(new SimpleCompiler()).runCompiler(args[ 0], args[1].equals("true"));
}
catch(IOException e) {
System. out. println(e. toString());
e. printStackTrace();
}
}

//provided, don't change this
public void runCompiler(String filename, boolean debug) throws IOException {
Node input = fileToQueue(filename);
System. out. println("\nProgram: " + Node. listToString(input));

if(!debug) {
while(input != null) {
input = compile(input, 10);
}
}
else {
Scanner s = new Scanner(System. in);
for(int i = 1; input != null; i++) {
System. out. println("\n Step " + i + " \n");
System. out. println("Step Output");
input = compile(input, 1);
System. out. println("Lookup BST");
System. out. println(symbols);
System. out. println("Call Stack");
System. out. println(callStack);
if(input != null) {
System. out. println("Program Remaining");
System. out. println(Node. listToString(input));
}
System. out. println("\nPress Enter to Continue");
s. nextLine();
}
}
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:30
Corey set up his presentation for delivery to his team.the information he had to convey was critical to their job performance.he knew he would need a lot of time to explain each point
Answers: 3
question
Computers and Technology, 22.06.2019 21:00
Ulia is planning to attend the same private four-year college her parents attended. she wants to save at least $18,000 in four years to contribute to her college education. which monthly deposit amounts can julia use to achieve her goal? check all that apply.
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
If you add the following to the query grid in an access query, what is it called? salestaxamt: [salestaxrate]*[totalsale] formula calculated field total calculation
Answers: 2
question
Computers and Technology, 24.06.2019 15:20
Local area networks use many of the same network technologies and the internet, only on a smaller scale. devices that access lans are equipped with a network interface that contains circuitry for wireless or wired connections. devices also have a physical address, in addition to the ip addresses acquired from a dhcp server. the most popular wired technology is . the most popular wireless technology is , which can be configured as a(n) or star topology. setting up a lan and configuring its router is fairly easy. the first step is to change the standard to one that is secure. next, create a(n) that uniquely identifies the network by name. it is also important to activate wireless to prevent wireless signals from being intercepted during transmission. a limited-access network can be created for visitors to use. by activating , the router will be able to assign ip addresses to each device that joins the network. to connect to a secure lan that is protected by encryption, an encryption , or password, is required. lans can be used to access data collected by iot devices and the networks that tie these devices together. technologies such as rfid, nfc, bluetooth smart, zigbee, and z-wave offer -power links, essential for battery-powered devices that can’t expend excess amounts of energy transmitting data.
Answers: 1
You know the right answer?
I need help in how to call a file in java: (file names are sample_input1.txt, sample_input2.txt, sam...
Questions
question
Mathematics, 21.01.2022 02:00
question
History, 21.01.2022 02:00
question
Mathematics, 21.01.2022 02:00
question
Physics, 21.01.2022 02:00