Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in C++, Im having trouble looping You're clearing out your pantry and you realize you have some ingredients you could throw together to make a
in C++, Im having trouble looping
You're clearing out your pantry and you realize you have some ingredients you could throw together to make a cake: cake flour, sugar, eggs, plus some flavorings. Since this happens often, you want to create a program that asks you how many ingredients you have and tells you if you have enough to create a particular cake. Write a program that does the following: prompt the user for what recipe they want to make and how much of each ingredient they have, and then output whether the user can make the recipe given those ingredients. The program should loop over a menu so that the user can make multiple queries in one session. Make sure to check for invalid input to the menu options. If the user tries to input a number that is not on the menu, print Invalid input." and then present the menu again. Item Recipe Vanilla Cake 440g cake flour 400g sugar 3 eggs 15g vanilla extract Chocolate Cake 440g cake flour 400g sugar 3 eggs 120g cocoa powder Pound Cake 440g cake flour 400g sugar 3 eggs 220g cream cheese Expected output 1 (bold is user input) Select a numerical option: === Menu === 1. Vanilla cake 2. Chocolate cake 3. Pound cake 4. Quit 1 How many grams of flour do you have? 500 How many grams of sugar do you have? 400 How many eggs do you have? 4 How many grams of vanilla extract do you have? 50 You can make a vanilla cake. Select a numerical option: === Menu === 1. Vanilla cake 2. Chocolate cake 3. Pound cake 4. Quit Goodbye Expected output 2 (bold is user input) Select a numerical option: --- menu -- 1. Vanilla cake 2. Chocolate cake 3. Pound cake 4. Quit 7 Invalid Input. Select a numerical option: === Menu === 1. Vanilla cake 2. Chocolate cake 3. Pound cake 4. Quit 4 Goodbye! Expected output 3 (bold is user input) ) Select a numerical option: --- menu 1. Vanilla cake 2. Chocolate cake 3. Pound cake 4. Quit 2 How many grams of flour do you have? 100 How many grams of sugar do you have? 400 How many eggs do you have? 2 How many grams of cocoa powder do you have? 200 You don't have enough for a chocalate cake. Select a numerical option: --- men --- 1. Vanilla cake 2. Chocolate cake 3. Pound cake 4. Quit 4 GoodbyeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started