Question

In Java please! Create a class WordCount that stores a String word and an int count....

In Java please!

Create a class WordCount that stores a String word and an int count. It should have the ability to retrieve the word and change the count. When you initialize a WordCount, you should specify the word and the count should start at 1.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class WordCount {
  private String word;
  private int count;

  public WordCount() {
    word = "";
    count = 1;
  }

  public WordCount(String word, int count) {
    this.word = word;
    this.count = count;
  }

  public String getWord() {
    return word;
  }

  public void setWord(String word) {
    this.word = word;
  }

  public int getCount() {
    return count;
  }

  public void setCount(int count) {
    this.count = count;
  }
}
Add a comment
Know the answer?
Add Answer to:
In Java please! Create a class WordCount that stores a String word and an int count....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help writing this code for java class. Starter file: Project3.java and input file: dictionary.txt...

    I need help writing this code for java class. Starter file: Project3.java and input file: dictionary.txt Project#3 is an extension of the concepts and tasks of Lab#3. You will again read the dictionary file and resize the array as needed to store the words. Project#3 will require you to update a frequency counter of word lengths every time a word is read from the dictionary into the wordList. When your program is finished this histogram array will contain the following:...

  • Create a java project and create Student class. This class should have the following attributes, name...

    Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...

  • Java using data structures The objective is to create your own Hash Table class to hold...

    Java using data structures The objective is to create your own Hash Table class to hold a list of employees and their ID numbers. I've provided the TableEntry class which will be each data object in the hash table. The list of employees will be provided as a .txt file and must be read with the code. please create a .txt file called Employees.txt with the info provided so that the java code can read it in. Employees.txt: (No WhiteSpace...

  • use java program, create a class with conditions below. 1. asking user to type int number...

    use java program, create a class with conditions below. 1. asking user to type int number 2.you have to receive it use next String (not next int) 3.use try catch , if user input is not int, ask them to retype int number. (have to print out message that said only type int number)

  • Write a JAVA code to do the following: create a class and add methods to count...

    Write a JAVA code to do the following: create a class and add methods to count the number of primitive fields, number of methods with primitive return types, a method that will also return the number of primitive in a given parameter. they are: public int getNumberOfPrimitiveMethods(Class host) public int getNumberOfPrimitiveFields(Class host) public int getNumberOfPrimitiveParameters(Method host) also public int getNumberOfPrivateMethods (Class host) public int getNumberOfPublicMethods (Class host)

  • In Java You are going to create a PhoneRecord class containing the following properties: firstName -...

    In Java You are going to create a PhoneRecord class containing the following properties: firstName - which is a String lastName - which is a String number - which should also be a String the properties will be public, and it should have two constructors: one which simply constructs the string and another that accepts values for first name, lastname and phone number. You should also create a class called Phone Book. It should contain an array of Phone Records...

  • CSC110 Lab 6 (ALL CODING IN JAVA) Problem: A text file contains a paragraph. You are to read the contents of the file, store the UNIQUEwords and count the occurrences of each unique word. When the fil...

    CSC110 Lab 6 (ALL CODING IN JAVA) Problem: A text file contains a paragraph. You are to read the contents of the file, store the UNIQUEwords and count the occurrences of each unique word. When the file is completely read, write the words and the number of occurrences to a text file. The output should be the words in ALPHABETICAL order along with the number of times they occur and the number of syllables. Then write the following statistics to...

  • create a java class with the name Brick class: For this part of the assignment, you...

    create a java class with the name Brick class: For this part of the assignment, you will create a class that allows you to specify a colored brick that is capable of drawing itself given a specified Graphics object. Note that this is a regular Java class and does not extend the JApplet class. Your class should a constructor with the following signature: Identifier: Brick(int xPosition, int yPosition, int width, int height, Color color) Parameters: xPosition – an int representing...

  • Money Lab using arraylists in Java Using the Coin class below create a program with the...

    Money Lab using arraylists in Java Using the Coin class below create a program with the following requirements Create an arraylist that holds the money you have in your wallet. You will add a variety of coins(coin class) and bills (ones, fives, tens *also using the coin class) to your wallet arraylist. Program must include a loop that asks you to purchase items using the coins in your wallet. When purchasing items, the program will remove coins from the arraylist...

  • Java: Create the skeleton. Create a new file called ‘BasicJava4.java’ Create a class in the file...

    Java: Create the skeleton. Create a new file called ‘BasicJava4.java’ Create a class in the file with the appropriate name. public class BasicJava4 { Add four methods to the class that return a default value. public static boolean isAlphabetic(char aChar) public static int round(double num) public static boolean useSameChars(String str1, String str2) public static int reverse(int num) Implement the methods. public static boolean isAlphabetic(char aChar): Returns true if the argument is an alphabetic character, return false otherwise. Do NOT use...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT