Question: The following code needs completing , method getToken() Increment k by 1 if k IS LESS THAN the length of expr Assign to token the

The following code needs completing , method getToken() Increment k by 1 if k IS LESS THAN the length of expr Assign to token the kth character of expr Put token to output file end if end method getToken

input-1.tx: 2-3

2*4*5

(1+2)*5

Given:

public class Main { static char token; static String expr; static int k = 0;

public static void main(String[] args)throws Exception{ Scanner scanner = new Scanner(new java.io.File("input-1.txt")); FileWriter myWriter = new FileWriter("output.txt");

//Read from the file while(scanner.hasNext()) { expr=scanner.nextLine();

}

} char getToken() { if(k < expr.length()) { token = expr.charAt(k); } }

}

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!