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, 23.06.2019 08:00
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
question
Computers and Technology, 23.06.2019 22:30
How many points do i need before i can send a chat
Answers: 1
question
Computers and Technology, 24.06.2019 14:00
What are the different components of the cloud architecture?
Answers: 2
question
Computers and Technology, 24.06.2019 17:50
Create a class hand in its own module. one object of class hand represents a hand of cards and so one object stores a number of card objects. for this assignment you will submit three separate modules, one with the definition of class card, one with the definition of class hand and one with the main application that thoroughly tests class hand.class hand must contain the following four methods: 1) , numcardsinhand) takes an integer as parameter and initializes a hand object with numcardsinhand card objects inside it. these card objects are generated randomly. for simplicity, assume an infinite number of decks of cards.2) bjvalue(self) returns the blackjack value for the whole hand of cards3) ) returns a string containing all the cards in the hand4) hitme(self) adds one randomly generated card to the handcreate a main program in its own module that thoroughly tests class hand. you will have three modules/files to upload to your etudes assignment submission: card.py, hand.py and the module that contains your main program.two alternatives for extra credit - you cannot get credit for both! (+1 point): after you have thoroughly tested the class hand and all of its methods, add code to your main program that stores one hand object as a pickle file and reads it back into a new hand object. you are only eligible for this extra credit if class hand has all four of the methods above working.or(+2 points): after you have thoroughly tested the class hand and all of its methods, add code to your main program that stores one hand object as a text file on the disk and reads it back into a new hand object. you are only eligible for this extra credit if class hand has all four of the methods above working.notes: -start by making any and all modifications suggested by my comments to your previous submission of class card from assignment #6 "a robust card object"-once your class card is tested and working well, you will not make any further modifications to it for the purposes of class hand.-you can keep the test code for class card intact. if it is indented inside an if __name__ == "__main__", then it will not be executed when your main program's module imports it.-to save time, write and test one method for class hand at a time.-under no circumstances are you to attempt the extra credit until you are completely finished with writing and testing all the methods in class hand.
Answers: 3
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, 15.10.2019 19:30
question
Spanish, 15.10.2019 19:30
Questions on the website: 13722361