NVIDIA drivers not working (Bumblebee and NVIDIA X Server Settings)

As you did not mention the Ubuntu edition you are using ... this is valid for all currently supported editions (12.04 | 14.04 | 16.04 | 16.10). Use this method to install the latest stable NVIDIA drivers !

First uninstall the currently installed NVIDIA drivers and bumblebee.
The solution to switch between the graphics adapters is nvidia-prime.

Boot the computer, mark the Ubuntu entry in the GRUB boot menu and press the E key.
Add nouveau.modeset=0 at the end of the linux line. Press the F10 key to boot Ubuntu.

When the login screen appears press Ctrl+Alt+F1.
Enter your user name and your password and execute :

sudo apt purge nvidia* bumblebee
sudo apt install ppa-purge
sudo ppa-purge bumblebee/stable
sudo ppa-purge xorg-edgers/ppa
sudo reboot  

Note : As I do not know which of the linked answers you tried, I just removed both PPAs ...
Now install the official NVIDIA drivers 375.26, which support NVIDIA GEFORCE GTX 840M.

Boot the computer, mark the Ubuntu entry in the GRUB boot menu and press the E key.
Add nouveau.modeset=0 at the end of the linux line. Press the F10 key to boot Ubuntu.

When the login screen appears press Ctrl+Alt+F1.
Enter your user name and your password and execute :

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-375 nvidia-prime
sudo reboot  

Important : Set a space between the last letter in the linux line and nouveau.modeset=0.
Switch between intel and NVIDIA graphics with NVIDIA X Server Settings -> PRIME Profiles.