Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the body of this method. Use a CharQueue to store the input line as it

ID: 3645193 • Letter: C

Question

Complete the body of this method. Use a CharQueue to store the input line as it is being read. The parameter is an EasyReader from Appendix B of the text. Use the method in.charInput( ) to read and return the next character of the EasyReader, and use in.isEOLN( ) to determine whether the next input character is the end-of-line.

public static int counter(EasyReader in)
// Precondition: There is a line of input waiting to be read from in.
// Postcondition: A line of input has been read from in, up to but not
// including the newline character. The return value of the method
// is the number of times that the LAST character of the line appeared
// somewhere in this line.
// EXAMPLE Input: ABBXDXXZX
// The value returned by counter would be 4 for this input since there
// are 4 X's in the input line.

Explanation / Answer

import java.io.*; public class GQueueT{ public static void main(String args[]){ PrintStream out = System.out; GQueue x= new GQueue(); out.println(x.toString()); x.join(new Integer(12) ); out.println(x.toString()); for(int i=23; i< 100; i+=11){ x.join(new Integer(i) ); } out.println("x.size()= "+ x.size()); out.println("x= "+ x.toString()); out.println("Successively leaving ..."); while(!x.isEmpty()){ out.println("front= "+x.front()); out.println(x.toString()); x.leave(); } } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote