The Word Counter is a simple Java program that counts the number of words in a given sentence. It utilizes the JOptionPane class for user input and graphical display.
- Conceptual Simplicity:
The project involves fundamental programming concepts such as input/output, string manipulation, and basic logic, making it accessible for beginners.
- Real-World Applicability:
Word counting is a common and practical task, and by building a Word Counter, beginners can see the immediate real-world applicability of their coding skills.
- I learnt how to use the split method to make sure it counts the words not character.
- Takes user input for a sentence.
- Splits the input into an array of words using the regular expression "\s+".
- Counts the number of words in the sentence.
- Displays the result using JOptionPane.
To use the Word Counter program, follow these steps:
- Clone this repository to your local machine.
- Compile the Java program: javac WordCounter.java
- Run the program: java WordCounter
- Java Development Kit (JDK) installed on your machine.
- An Integrated Development Environment (IDE) like IntelliJ IDEA or Eclipse (optional).
-
Clone the repository:
git clone https://github.com/jennyemeka/word-counter.git
-
Open the project in your preferred IDE or compile and run using the command line.
-
Run the WordCounter class.
-
Enter a sentence when prompted.
-
The program will display the number of words in the sentence using JOptionPane.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, feedback, or collaboration opportunities, please contact me at jenniferemeka24@gmail.com.
Your feedback and contributions are highly appreciated!