Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

Compare andcontrast the three types of addresses used in a network.

Answered: 1 week ago

Question

The amount of work I am asked to do is reasonable.

Answered: 1 week ago

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago