Question
To keep track of the number of visitors that meet up with Gus each day, we need to keep an accurate tally. You will be
To keep track of the number of visitors that meet up with Gus each day, we need to keep an accurate tally. You will be creating the class TallyCounter which we will use and modify throughout the week. Details for this class are given below.
import java.util.*;
public class PoD
{
public static void main (String [] arg )
{
Scanner in = new Scanner( System.in );
String nextTask;
TallyCounter tally = new TallyCounter();
while (in.hasNext())
{
nextTask = in.next();
if (nextTask.equals("increment"))
{
tally.increment();
}
if (nextTask.equals("get"))
{
System.out.println(tally.get());
}
}
System.out.print("END OF OUTPUT");
in.close();
}
}
public class TallyCounter {
// PLEASE START YOUR CODE HERE
// *********************************************************
// *********************************************************
// PLEASE END YOUR CODE HERE
}
Input In the file TallyCounter.java you will create the TallyCounter class. This class will require field necessary to keep track of a count of museum visitors. The counter must start at zero Processing The TallyCounter must keep track of the count. You will create the necessary field members for all needs of the class. A TallyCounter has two methods (so farl): the increment0 method and the get( method. These methods do the following: increment) : This method increases the total count by one. This method is used when a new visitor comes to visit Gus. One more visitor, one more push of the TallyCounter button to increment the count by one get) This method returns an integer count of the number of visitors that have been by to see Gus so far You will need to set up the TallyCounter class, including field members, constructors and methods. The main method of PoD.java will instantiate a new TallyCounter and read in methods to call Output The get() method returns an integer valueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started