What's the code?

Write a program that asks the user for the following things:

The names of three ingredients for a salad recipe.
The number of ounces of each ingredient required for one serving (these should just be floats, like 2.5).
The number of servings desired (this should be an integer). You should only ask for the number of servings once.
The program should then output the total number of ounces of each ingredient required to make the desired number of servings.

Respuesta :

Answer:

Explanation:

#include <iostream>

using namespace std;

// Recipe of single portion salad

int main()

{

   float Qing[3]={0.0,0.0,0.0};

   string ItemName[3]={" "," "," "};

   int qty=0;

   cout<<"Please enter 3 Ingredients required for Salad and Quantity required for a single serve"<<endl;

   for (int i=0;i<3;i++)

   {

       cout<<"Enter the ingredient number "<<(i+1)<<" :";

       cin>>ItemName[i];

       cout<<"Qty required for single serve (in Oz) :";

       cin>>Qing[i];

   }

   cout<<"Number of servings required :";

   cin>>qty;

   cout<<endl<<"Total Quantities required for "<<qty<<" servings"<<endl;

   for (int i=0;i<3;i++)

   {

       cout<<ItemName[i]<<" Qty for "<<qty<<" servings :"<<(Qing[i]*qty)<<" Oz."<<endl;

   }

   return 0;

}

// You can run this after compiling without any problem.