Seems to be a contact problem.
. Check the battery contacts. If they look clean and shiny that is fine. If the contacts are recessed as in the D3300, then check if any dust or foreign matter has got into the recess. Blow hard to get rid of any matter if it is there.
. Check the contacts in the camera. Shine a torch and check them. If they are shiny they are fine. If there is slight dust or they look dull, blow and if that does not solve the problem, try cleaning them with thin ear buds.
. As suggested try another battery. If problem disappears, it is the battery.
If every thing is fine and the problem persists, then the contacts in the camera are to blame. If in warranty get it checked and repaired.