I used to work for a big name computer company & usually received a lot of call regarding your issue.
You don't need to immediately send the whole computer in for repair. You still have 2 months before the warranty runs out.
1st trouble shooting step, take out the battery & have the computer run on AC power alone & observe if it will still shut down randomly. If it does not, that means the battery has gone bad already.
Immediately call HP's toll-free hotline number (1-800-4746836) for further assistance from the Phone Tech Support Team. Write down the name of the person who will take your call & ask them to register your laptop on-line because you need to order a replacement battery, the charger (adapter) & the power cord for the charger (tell them the charger is malfunctioning that's why your battery went bad early).
FYI, which ever country your call will be routed to, please be patient & polite to the person who will take your call. After all, you are the one calling them for assistance with whatever issue you are having with your portable computer. Make sure to speak your name clearly (spell it, if need be) & provide all the info needed & asked for. They are trained professionals for handling simple matters, so I believe they should be able to assist you w/ any issue as long as IT IS WITHIN THEIR SCOPE OF SUPPORT. It depends on the company but be cooperative because these phone technicians have a specific handle time to be able to resolve the issue of a caller, so please do not be a jerk. Listen carefully to their instructions & follow it, because IF YOU THINK YOU KNOW MORE, then WHY CALL FOR ASSISTANCE IN THE FIRST PLACE.
If it does, then it is a motherboard issue that means you really need to send the whole computer in for repair. Same thing, call HP & ask for their assistance in registering your laptop b'coz you need to send the whole computer in for repair.
Before you send it in for repair which takes about a month, make sure to back-up all your pictures, files & important documents on your computer on an external Hard Drive or USB Flash Drive, b'coz if you send your computer in for repair, they will erase all the data in it & restore it back to factory settings just like when you first got it out of the box.
DO NOT SEND THE CHARGER & THE POWER CORD. Just the computer w/ the battery in it.
Although, if you would ask me. I'll have both the battery, charger & the charger's power cord, all replaced before I send the whole computer in for Depot Repair, b'coz it might get misplaced or replaced with a used one.
Additional info, read on:
A brand new computer's battery comes w/ a Standard 1yr Limited Warranty w/c means the expected life time of battery is only 1 year. Same thing goes for the charger.
So, if you don't know how to take care of it, it will die out on you sooner than than expected.
FYI: I always tell my customers, a laptop's battery is similar to a cell phone's. You charge it when it's depleted & you unplug the adapter when it is already fully charge (this will prevent the battery from getting overcharged & extend the life of the battery). So for less hassle, I always advice my customers to JUST REMOVE THE BATTERY IF THEY PLAN TO USE THE COMPUTER FOR LONG HOURS STRAIGHT (more than 1 hour) and just run it on AC power alone so as not to overcharge it & shorten the battery life.
ONLY USE THE BATTERY FOR PORTABILITY, if you need to go on a trip or you're at McDonalds or Starbucks.
For chargers, make sure you don't stretch out the cable too much that the one by the power jack that you plug into the side of the computer gets bent. Make sure this part is always straight or else the copper wires inside will break & soon you'll have the problem of the charger not working anymore like what happened to some of my callers.