COS1511 ASSIGNMENT 1 SOLUTIONS 2021
Question 1)
#include <iostream>
using namespace std;
int main()
{
int mFactor;
cout<<"Please enter the factor to multiply the ingredients with : ";
cin>>mFactor;
cout<<"Cup cake"<<endl;
cout<<"\tIngredients"<<endl;
cout<<"\t\t"<<1*mFactor<<" cups of sugar"<<endl;
cout<<"\t\t"<<2*mFactor<<" cups of milk"<<endl;
cout<<"\t\t"<<4*mFactor<<" cups of flour"<<endl;
return 0;
}
, Question 2)
#include <iostream>
using namespace std;
int main()
{
int nrPupils, nrGroups, nrLeft;
nrPupils = 56;
int gruopSize;
cout<<"Please enter the size of each group? ";
cin>>gruopSize;
nrGroups = nrPupils / gruopSize;
nrLeft = nrPupils % gruopSize;
cout<<endl<<"There are "<<nrGroups<<" groups consisting of "<<gruopSize<<" pupils"<<endl;
cout<<"There are "<<nrLeft<<" remaining pupils "<<endl;
return 0;
}
Question 1)
#include <iostream>
using namespace std;
int main()
{
int mFactor;
cout<<"Please enter the factor to multiply the ingredients with : ";
cin>>mFactor;
cout<<"Cup cake"<<endl;
cout<<"\tIngredients"<<endl;
cout<<"\t\t"<<1*mFactor<<" cups of sugar"<<endl;
cout<<"\t\t"<<2*mFactor<<" cups of milk"<<endl;
cout<<"\t\t"<<4*mFactor<<" cups of flour"<<endl;
return 0;
}
, Question 2)
#include <iostream>
using namespace std;
int main()
{
int nrPupils, nrGroups, nrLeft;
nrPupils = 56;
int gruopSize;
cout<<"Please enter the size of each group? ";
cin>>gruopSize;
nrGroups = nrPupils / gruopSize;
nrLeft = nrPupils % gruopSize;
cout<<endl<<"There are "<<nrGroups<<" groups consisting of "<<gruopSize<<" pupils"<<endl;
cout<<"There are "<<nrLeft<<" remaining pupils "<<endl;
return 0;
}