Welcome! 👋 This is a straightforward exercise — we just want to see how you approach a real-world problem using Java. Take your time, read everything carefully, and have fun with it.
You'll be working with a dataset of hotels stored in a JSON file located at:
src/main/resources/hotels.json
Each hotel entry looks like this:
{
"name": "Blue Three Miami",
"city": "Miami",
"state": "Florida",
"country": "US",
"amenities": "Free Wifi|Garden|Cleaning services|Laundry|Breakfast",
"rating": 7.3,
"reviews": "1236"
}Your goal is to implement the main method in src/main/java/codechallenge/Application.java so that it reads this file and answers the three questions below.
Print the names of all top-rated hotels.
A hotel is considered top-rated if it meets both of the following criteria:
- Rating is higher than 7.0
- Number of reviews is more than 1000
Print the names of all hotels that offer "Bar" as one of their amenities.
Sort the full dataset and print it as a formatted JSON array.
Sort rules (apply in order):
- Highest rating first (descending)
- If there's a tie in rating, most amenities first (descending)
You're welcome to add new keys to each hotel entry in the output (for example, to store a computed value), but please do not modify or remove any of the existing keys.
- It's okay to use any libraries you're comfortable with — feel free to update
build.gradleif needed. - There's no single right answer — we're interested in how you structure your code and your reasoning, not just the final output.
- Feel free to create additional classes if that makes things cleaner.
This project uses the Gradle Wrapper, so you don't need to install anything extra beyond a JDK.
From the project root directory, run:
./gradlew clean runThe application should print the answers to the three questions to the console. But you can implement the individual answers incrementally.
Tip: If you're on Windows, replace
./gradlewwithgradlew.batin all commands above.
Good luck — you've got this! 🚀