Answer to Question #330542 in C++ for LM.

Question #330542

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. Submit both your program and output.


1
Expert's answer
2022-04-20T03:44:58-0400
#include <iostream>


int main() {
  int mFactor;
  std::cout << "Please enter the factor to multiply the ingredients with: ";
  std::cin >> mFactor;
  std::cout << "\nCoffee with milk recipe for " << mFactor << " persons\n-------------------------------------\n";
  std::cout << "Ingredients:\n";
  std::cout << "coffee: " << 100 * mFactor << " ml\n";
  std::cout << "milk:   " << 200 * mFactor << " ml\n";
  std::cout << "sugar:  " << 2 * mFactor << " teaspoons\n\n";
  std::cout << "How to make it:\nMix everything and drink!\n\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