Autofocus stopped working on Nikon D7200 with Nikon 18-300 lens
I'm referring to the below image...
On the lens barrel, note the sliding switch "M" and "A". "M" means manual focus. Make sure this switch is set to "A".
On the camera body, at the very bottom-right in this image, is a small lever switch. It shows the options "AF" and "M". Set to "AF" for auto-focus.
Both the camera body and the lens must be set to auto focus.
It's more likely the lens than the camera. Try reattaching the lens and if that doesn't work remove and replace the camera's battery. Nikon has good warranty policies if that doesn't work.