Question: Please use Java to compile...Thanks a lot. I am sorry, I forgot to say use what language. The Sandwich Conundrum We're going on a picnic.
Please use Java to compile...Thanks a lot. I am sorry, I forgot to say use what language.
The Sandwich Conundrum We're going on a picnic. We are making peanut butter and jelly sandwiches. We want to find out how many sandwiches we can make with out having any bread, peanut butter, or jelly left over. Each loaf of bread has 22 slices, each jar of peanut butter can make 18 sandwiches, and each jar of jelly can make 24 sandwiches. Create a class with a main method for this program. At minimum, declare appropriate constants for the number of sandwiches each item will make, variables to keep up with number of each item purchased, and the number of sandwiches left for the each current bread loaf, peanut butter jar and jelly jar. Run your simulation by assuming you start with one loaf of bread, one jar of peanut butter and one jar of jelly. Use a loop to drive the simulation. Each iteration of the loop represents the making of a sandwich. Design the control of your loop to end when you have run out of bread, peanut butter and jelly at the same time. In your loop if you run out of one before the other simulate purchase of a new item and set the number left back to the number of sandwiches that that item can make. Keep count of each item purchase so that you can display the number of loaves of bread, jars of peanut butter and jars of jelly purchased after your loop completes when you have nothing left. Also display the total number of sandwiches made
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
