Skip to content

Repository files navigation

Java Code Challenge

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.


The Challenge

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.


Questions

1. Top-Rated Hotels

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

2. Hotels with a Bar

Print the names of all hotels that offer "Bar" as one of their amenities.


3. Sorted Dataset

Sort the full dataset and print it as a formatted JSON array.

Sort rules (apply in order):

  1. Highest rating first (descending)
  2. 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.


Notes & Tips

  • It's okay to use any libraries you're comfortable with — feel free to update build.gradle if 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.

How to Run

This project uses the Gradle Wrapper, so you don't need to install anything extra beyond a JDK.

Run the application

From the project root directory, run:

./gradlew clean run

The 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 ./gradlew with gradlew.bat in all commands above.


Good luck — you've got this! 🚀

About

Simple repository for assessing candidates' proficiency in Java language

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages