Question

A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup...

A cookie recipe calls for the following ingredients:

• 1.5 cups of sugar

• 1 cup of butter

• 2.75 cups of flour

The recipe produces 48 cookies with this amount of the ingredients. Write a program that asks the user how many cookies he or she wants to make, and then displays the number of cups of each ingredient needed for the specified number of cookies

Homework Answers

Answer #1

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
   int cookies;
   double sugar,butter,flour;
  
   cout<<"How many cookies you want to make?";
   cin>>cookies;
  
   sugar = 1.5/48 * cookies;
  
   flour = double(1)/48 * cookies;
  
   butter = 2.75/48 * cookies;
   cout<<fixed<<setprecision(2); //set precision of 2 decimal places
  
   cout<<"\nFor "<<cookies<<" cookies following ingredients are required";
  
   cout<<"\n"<<sugar<<" cups of sugar";
  
   cout<<"\n"<<flour<<" cups of flour";
      
   cout<<"\n"<<butter<<" cups of butter";
  
   return 0;
}

output:

How many cookies you want to make?96
For 96 cookies following ingredients are required
3.00 cups of sugar
2.00 cups of flour
5.50 cups of butter
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
A cookie recipe calls for the following ingredients: 1.5 cups of sugar 1 cup of butter...
A cookie recipe calls for the following ingredients: 1.5 cups of sugar 1 cup of butter 2.75 cups of flour The recipe produces 48 cookies with this amount of the ingredients. Write a program that asks the user how many cookies he or she wants to make, and then displays the number of cups of each ingredient needed for the specified number of cookies. In Java code please.
Stephen is the father of three physically active children, ages 3, 8, and 12 years. He...
Stephen is the father of three physically active children, ages 3, 8, and 12 years. He is concerned about his children’s health because they experience frequent constipation. The favorite family “treat” is homemade oatmeal cookies. Stephen would like to make the cookies higher in fiber and lower in sugar and solid fat than the original recipe. Grandma’s Oatmeal Cookies Ingredients: 1 cup butter, softened 1 cup white granulated sugar 1 cup brown sugar, packed 2 eggs 1 tsp vanilla extract...
Here is a recipe for macaroni and cheese. Ingredients 1 cup elbow macaroni 1 1/2 cups...
Here is a recipe for macaroni and cheese. Ingredients 1 cup elbow macaroni 1 1/2 cups shredded Cheddar cheese 2/3 cup milk 1 egg, beaten 1 tablespoon mustard 1 dash hot pepper sauce Select two ingredients that you feel will make the most significant changes to make this recipe healthier. Name your two ingredients, explain how you are going to make modifications to the two ingredients and discuss the nutrient changes as a result. Remember you are modifying ingredients and...