A simple chat bot project written in Java that helps users interact through a command-line interface with interesting features like age guessing, number counting, and programming knowledge testing.
This is an educational chat bot designed to help programming beginners. The bot can:
- Greet and remember user names
- Guess age through mathematical algorithms
- Count from 0 to any number the user inputs
- Test programming knowledge through multiple-choice questions
- Bot introduces itself with name and creation year
- Asks for and remembers user's name
- Uses Chinese Remainder Theorem algorithm
- User inputs remainders when dividing age by 3, 5, and 7
- Bot calculates and accurately guesses the age
- Counts from 0 to user-specified number
- Displays each number sequentially
- Presents multiple-choice questions about programming
- Repeats questions until user answers correctly
- Congratulates upon completion
- Language: Java
- Framework: Standard Java (no external frameworks)
- I/O: Scanner for user input
- Testing: JUnit for unit testing
Simple-Chat-Bot-with-Java/
├── Simple Chat Bot with Java/
│ ├── task/
│ │ ├── src/
│ │ │ └── bot/
│ │ │ └── SimpleBot.java # Main file containing bot logic
│ │ ├── test/
│ │ │ └── Tests.java # Test cases file
│ │ └── build/ # Build and reports directory
│ ├── Meet your chat bot/
│ │ └── task.html # Stage 1 instructions
│ ├── Teach your bot to count/
│ │ └── task.html # Stage 2 instructions
│ └── Play a simple quiz together/
│ └── task.html # Stage 3 instructions
└── README.md
- Java JDK 8 or higher
- Java IDE (IntelliJ IDEA, Eclipse, or VS Code)
-
Clone repository
git clone https://github.com/hieudq05/Simple-Chat-Bot-with-Java.git cd Simple-Chat-Bot-with-Java -
Compile and run
cd "Simple Chat Bot with Java/task/src" javac bot/SimpleBot.java java bot.SimpleBot
-
Or use IDE
- Open project in IDE
- Navigate to
SimpleBot.java - Run the main file
Hello! My name is Aid.
I was created in 2018.
Please, remind me your name.
> John
What a great name you have, John!
Let me guess your age.
Enter remainders of dividing your age by 3, 5 and 7.
> 1
> 0
> 3
Your age is 25; that's a good time to start programming!
Now I will prove to you that I can count to any number you want.
> 5
0!
1!
2!
3!
4!
5!
Let's test your programming knowledge.
Why do we use methods?
1. To repeat a statement multiple times.
2. To decompose a program into several small subroutines.
3. To determine the execution time of a program.
4. To interrupt the execution of a program.
> 2
Congratulations, have a nice day!
The project includes test cases to ensure accuracy:
# Run tests (if using Gradle)
./gradlew test
# Or run Tests.java directly
javac test/Tests.java
java TestsThe bot uses the Chinese Remainder Theorem to guess age:
int age = (rem3 * 70 + rem5 * 21 + rem7 * 15) % 105;greet()- Greets and gets user nameremindName()- Remembers and responds to nameguessAge()- Guesses age through algorithmcount()- Counts numbers as requestedtest()- Tests programming knowledgeend()- Ends with congratulations
This project demonstrates:
- Method decomposition in Java programming
- User input handling with Scanner
- Mathematical algorithms implementation
- Loop structures and control flow
- Basic testing practices
All contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Project is built in stages (incremental development)
- Each stage has its own
task.htmlfile with detailed instructions - Code is well-organized with separate methods for each functionality
- Follows Java naming conventions and best practices
Potential improvements could include:
- GUI interface using Swing or JavaFX
- More quiz categories and questions
- Save/load user preferences
- Multi-language support
- Advanced conversation features
- Author: hieudq05
- GitHub: @hieudq05
- Repository: Simple-Chat-Bot-with-Java
- Created: June 28, 2025
This project is open source and available under the MIT License.
⭐ If you find this project helpful, please give it a star to show your support!
java chatbot beginner-friendly educational console-application programming-tutorial algorithm interactive