Answer to Question #189665 in C++ for Sydney Nthane

Question #189665

Find a good cookbook. Read the instructions for your favourite dish. Write a program to display the recipe on the screen but with a difference. The quantity of each ingredient must be multiplied by a value entered from the keyboard. For example, if the recipe needs 2 cups of flour the output displayed will be something like this Please enter the factor to multiply the ingredients with : 4 Recipe name Ingredients // other ingredients 8 cups flour Method The program has the following structure:  Declare an int variable named mFactor to store the value with which the quantity of each ingredient must be multiplied.  The program must make use of a cin statement to input a value from the keyboard and store it in mFactor


1
Expert's answer
2021-05-07T05:01:46-0400
#include <iostream>
using namespace std;
int main(){
    int mFactor = 1;
    cout<<"Please enter the factor to multiply the ingredients with: ";
    cin>>mFactor;
    cout<<"Recipe to bake a basic vanilla cake\nIngredients:\n";
    cout<<2 * mFactor<<" sticks of unsalted butter\n";
    cout<<3 * mFactor<<" cups of all-purpose flour\n";
    cout<<1 * mFactor<<" tablespoons of baking powder\n";
    cout<<1 * mFactor<<" teaspoons of salt\n";
    cout<<1 * mFactor<<" cups of sugar\n";
    cout<<4 * mFactor<<" large eggs\n";
    cout<<1 * mFactor<<" tablespoons of vanilla extract\n";
    cout<<1 * mFactor<<" cups of whole milk\n";
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS