Adding onto bart's answer
To OP: When flashing a new rom to the phone, you have two options to choose
Flashing with the program called ODIN and downloaded firmware from Sammobile.com. Instructions on how to do so are on Sammobiles website.
or
Doing a system restore via Samsung Kies / (Maybe Smart Switch is used instead) to allow the software to download the correct firmware for you using your provided model number and serial number.
Hard reset instructions are as follows: Take battery out. Wait 5 seconds. Put battery in. Hold Power + Volume Up + Home button to boot recovery mode. When Samsung logo pops up stop holding the power button but keep holding the rest. Release all other buttons once the Recovery Menu with the blue text or other colored text pops up.
Use volume up and down to navigate the menu. Highlight / select 'Wipe Data / Factory Reset' then hit the button to confirm the selection. It will ask you if you really want to do a factory reset. Navigate the selections and select yes to perform the selected task.
Once that's done, reboot phone from recovery. Hopefully this works otherwise use the instructions in this comment to help you restore / reflash firmware onto the phone.