100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Other

COS1511 Assignment 01 Solutions

Rating
-
Sold
-
Pages
8
Uploaded on
16-04-2022
Written in
2021/2022

Here you will find all the solutions to COS1511 assignment 01.

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
April 16, 2022
Number of pages
8
Written in
2021/2022
Type
Other
Person
Unknown

Subjects

Content preview

COS1511 ASSIGNMENT 01
UNIQUE NUMBER: 830138


Question 1.
#include <iostream>
using namespace std;
int main()
{
int mFactor;
cout << "Please enter the factor to multiply the ingredients with :";
cin >> mFactor;
cout << "Recipe name" << endl;
cout << "\tIngredients" << endl;
cout << "\t\t" << 1*mFactor << " cups of all purpose flour" << endl;
cout << "\t\t" << 2*mFactor << " tablespoons of white sugar" << endl;
cout << "\t\t" << 2*mFactor << " teaspoons of baking powder" << endl;
cout << "\t\t" << 1*mFactor << " teaspoons of salt" << endl;
cout << "\t\t" << 1*mFactor << " egg" << endl;
cout << "\t\t" << 2*mFactor << " tablespoons of sunflower seed/olive oil" << endl;
cout << "\t\t" << 1*mFactor << " cups of milk" << endl;
cout << "\tMethod" << endl;
cout << "\t\tStep 1: Mix flour, sugar, baking powder and salt in a large bowl." << endl;
cout << "\t\tStep 2: Make a hole in the center of the bowl, which has all the mixed ingredients." <<
endl;
cout << "\t\tStep 3: Now pour the milk, beaten egg and oil in the centre of the bowl, and then mix
everything until it is smooth." << endl;
cout << "\t\tStep 4: Lightly pour oil on a frying pan, and heat the frying pan with medium high heat
on a stove." << endl;
cout << "\t\tStep 5: Pour/scoop the mixture on the frying pan, using approximately a quarter (1/4)
of a cup for each pancake." << endl;
cout << "\t\tStep 5: Flip then remove the pancake when it is brown on both sides (note: they
should not burn or turn black)" << endl;
cout << "\t\tStep 6: Recommend to SERVE WHILE IT IS HOT!!!" << endl;
return 0;
}

, Question 2.
#include <iostream>
using namespace std;
int main()
{
int nrPupils = 56, nrGroups, nrLeft, groupSize;
cout << "Please enter the size of each group: " << endl;
cin >> groupSize;
nrGroups = nrPupils/groupSize;
nrLeft = nrPupils - nrGroups*groupSize;
cout << "There are " << nrGroups << " groups consisting of " << groupSize << " pupils. There are "
<< nrLeft << " remaining pupils." << endl;
return 0;
}




Question 3.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float var1, var2;
char operation;
cout << "Please enter the first float value: ";
cin >> var1;
cout << "Please enter the second float value: ";
cin >> var2;
cout << "Please enter the operation required: ";
cin >> operation;
cout << setiosflags(ios::fixed) << setprecision(2);
if (operation == '+')
cout << "The sum of " << var1 << " and " << var2 << " is " << var1+var2 << endl;
else if (operation == '-')
cout << "The difference of " << var1 << " and " << var2 << " is " << var1-var2 << endl;
else if (operation == 'x')
cout << "The multiplication of " << var1 << " and " << var2 << " is " << var1*var2 << endl;
else if (operation == '/')
cout << "The division of " << var1 << " and " << var2 << " is " << var1/var2 << endl;
else if (operation == '%')
cout << "The modulus of " << var1 << " and " << var2 << " is " << (static_cast<int32_t>(var1))%
(static_cast<int32_t>(var2)) << endl;
$4.50
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
segodithabang

Get to know the seller

Seller avatar
segodithabang University Of South Africa
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
4 year
Number of followers
1
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions