Hi there Mary and welcome
Can you do the following please.
Then once the Mac has started, tell me if it now stays shut please
Power off the mac
Then start the Mac and hold down the Command and R keys at startup.
Hold these keys until the Apple logo appears. After your computer finishes starting up, you should see a desktop with an OS X menu bar and an OS X Utilities window
choose Disk Utility from the Utilities window, or from the Installer menu if you're started from an installation disc.
Click the First Aid tab.
Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
Select your Startup Disk (usually named "Macintosh HD").
Click Repair. Disk Utility checks and repairs the disk.
Let this complete and when it has, tell me if you still have the problem please.
It is the internal DVD drive that has faulted, this now confirms it
I am really sorry about this and you are going to have to return the Mac to have this replaced. It will be covered by the warranty if this has not expired, and the replacement will be done at no cost to you.
I am really sorry about this, and if you have problems, or would like any additional information or assistance, please do not hesitate to let me know.
And if you can take a second to rate my service by clicking one of the stars at the top of the page, then submit, that would be greatly appreciated.