Could be several things...which means you have to methodically work through each possible scenario.
Obviously you have tried resetting the camera to over ride any settings hat may be causing the issue to start with...which brings you to the next set of diagnostic scenarios.
A ) does the problem repeat itself when you try iauto as opposed to programmed setting...if yes..then it is likely to be aperture related if it's the lens. ..so the next step is to try using a different lens...or no lens at all...you need to go into menu and set ..shoot with out lens...then take a picture indoors at a low light source..if the image is still dark....it points to the sensor....try putting the ISO up to 3200 and check if it is still dark...sensors on nikons don't usually fail.it could be a ribbon connector has dislodged due to an unwarranted knock....on no account try taking a picture in extreme sunlight with the lens...this can damage the sensor....
Going back to the other possibility...lens aperture mechs can fail without warning and just produce dark pictures at all speeds and apertures.It is possible to overhaul these but usually the aperture mech needs replacing.