ASSSIGNMENT 1 SOLUTIONS
QUESTION 1
#include<iostream>
using namespace std;
int main()
{
int mFactor;
//takes input from the user for the value of mFactor
cout<<"Please enter the factor to multiply the ingredients with: ";
cin>>mFactor;
cout<<"\nItalian Noodles Recipe"<<endl;
cout<<"\tIngredients"<<endl;
//Ingredients quantity is multiplied with mFactor wherever a number
appears.
cout<<"\t\t"<<1*mFactor<<" packet of Instant
noodles"<<endl<<"\t\t"<<1*mFactor<<" teaspoon
Oil"<<endl<<"\t\t"<<2*mFactor<<" Garlic Cloves finely
chopped"<<endl<<"\t\t"<<1*mFactor<<" cup Mushrooms
diced"<<endl<<"\t\t"<<1*mFactor/2<<" cup Red Pasta
Sauce"<<endl<<"\t\t"<<1*mFactor/4<<" teaspoon Oregano
dried"<<endl<<"\t\t"<<2*mFactor<<" tablespoons Olives
sliced"<<endl<<"\t\t"<<"A few Basil leaves"<<endl<<"\t\t"<<2*mFactor<<"
tablespoon Cheese grated"<<endl<<"\t\t"<<"Salt to taste"<<endl;
cout<<"\n\tMethod"<<endl;
cout<<"\t\t1. Cook the noodles according to package directions without
the tastemaker/masala."<<endl<<"\t\t2. Drain and set aside."<<endl<<"\t\t3.
Heat oil in a pan and add garlic. Saute for a minute."<<endl<<"\t\t4. Now
add mushrooms and cook the mushrooms for two minutes."<<endl<<"\t\t5. Now,
add pasta sauce, oregano and the noodles."<<endl<<"\t\t6. Bring this to a
quick simmer and switch off the flame."<<endl<<"\t\t7. Top with olives,
basil and cheese. Serve immediately.";
return 0;
}
Output:
, QUESTION2
using namespace std;
int main()
{
//Variables declared
int nrPupils,nrGroups,nrLeft,groupSize;
nrPupils=56;
//Input statement
cout<<"Please enter the size of each group? ";
cin>>groupSize;
//Calculate nrGroups and nrLeft
nrGroups=nrPupils/groupSize;
nrLeft=ceil((nrPupils-(nrGroups*groupSize))+((nrPupils/(float)groupSize)-nrGroups));
//Display Result
cout<<"\nThere are "<<nrGroups<<" groups consisting of "<<groupSize<<" pupils"<<endl;
cout<<"There are "<<nrLeft<<" remaining pupils"<<endl;
return 0;
}
**Code ended**
Output: