I am new to programming. What I would like to do is once the choice is made and the user knows how much they have saved, that goes into a .txt file stamped with the date and time. My question is does the ofstream go inside the switch case or outside?
Also, is there a more efficient way to store the variables for lunch places rather then keep declaring them over and over? This is not a homework assignment this is for me.
I would put the ofstream after the switch. What's the purpose of choiceoflunch = McDonalds; and the others? Maybe you have a reason for it later, but with the code you've posted here I don't see any reason to do it. Also, choiceoflunch is an int, but the prices are doubles. You are losing everything after the decimal by doing this.
This is a good example of where data is better than code. What if you decide you would have eaten at Wendy's instead? You'd have to change a whole lot of code. Here's a version where the restaurant names and prices are stored in a separate text file: