Professional Documents
Culture Documents
SCHOOL OF EDUCATION
INSTRUCTIONS:
i. Please
take
your
time
to
read
and
follow
the
instructions.
ii. Do
the
work
on
a
sheet
of
paper
(s)
with
your
NAME
and
ID
on
each
page
(Preferably
A4).
iii. When
done,
take
a
picture
of
your
work.
(You
can
use
Microsoft
Office
Lens
mobile
app
to
assist
you).
iv. Submit
your
work
by
uploading
the
pictures.
v. Follow
the
training
manuals
for
assistance.
PART B 50 MARKS
Input
Validation:
The
program
should
make
sure
that
the
number
of
calories
is
greater
than
0,
the
number
of
fat
grams
is
0
or
more,
and
the
number
of
calories
from
fat
is
not
greater
than
the
total
number
of
calories.
[7 marks]
Page
2
of
4
Question 2 [10 marks]
a) Calories
Burned
Running
on
a
particular
treadmill
you
burn
3.9
calories
per
minute.
Write
a
program
that
uses
a
loop
to
display
the
number
of
calories
burned
after
10,
15,
20,
25,
and
30
minutes.
[5 marks]
b) Restaurant Bill
Write
a
program
that
computes
the
tax
and
tip
on
a
restaurant
bill
for
a
patron
with
a
GHC44.50
meal
charge.
The
tax
should
be
6.75
percent
of
the
meal
cost.
The
tip
should
be
15
percent
of
the
total
after
adding
the
tax.
Display
the
meal
cost,
tax
amount,
tip
amount,
and
total
bill
on
the
screen.
[5 marks]
a)
char sure;
do
{
cout << "Are you sure you want to quit? ";
cin >> sure;
} while (sure != 'Y' && sure != 'N');
[2.5 marks]
int count = 0;
while (count < 50)
{
cout << "count is " << count << endl;
count++;
}
[2.5 marks]
Page
3
of
4
b) Average
Rainfall
Write
a
program
that
calculates
the
average
monthly
rainfall
for
three
months.
The
program
should
ask
the
user
to
enter
the
name
of
each
month,
such
as
June
or
July,
and
the
amount
of
rain
(in
inches)
that
fell
that
month.
The
program
should
display
a
message
similar
to
the
following:
The
average
monthly
rainfall
for
June,
July,
and
August
was
6.72
inches.
[5 marks]
Question 4 [15 marks]
a) Population
Write
a
program
that
will
predict
the
size
of
a
population
of
organisms.
The
program
should
ask
the
user
for
the
starting
number
of
organisms,
their
average
daily
population
increase
(as
a
percentage
of
current
population),
and
the
number
of
days
they
will
multiply.
A
loop
should
display
the
size
of
the
population
for
each
day.
Input
Validation:
The
program
should
not
accept
a
number
less
than
two
for
the
starting
size
of
the
population,
a
negative
number
for
average
daily
population
increase,
or
a
number
less
than
one
for
the
number
of
days
they
will
multiply.
[8 marks]
Scientists
measure
an
object’s
mass
in
kilograms
and
its
weight
in
newtons.
If
you
know
the
amount
of
mass
that
an
object
has,
you
can
calculate
its
weight,
in
newtons,
with
the
following
formula:
Weight = mass × 9.8
Write
a
program
that
asks
the
user
to
enter
an
object’s
mass,
and
then
calculates
and
displays
its
weight.
If
the
object
weighs
more
than
1,000
newtons,
display
a
message
indicating
that
it
is
too
heavy.
If
the
object
weighs
less
than
10
newtons,
display
a
message
indicating
that
the
object
is
too
light.
[7 marks]
SUBMISSION
INSTRUCTION
i. Please
take
your
time
to
read
and
follow
the
instructions.
ii. Do
the
work
on
a
sheet
of
paper
(s)
with
your
NAME
and
ID
on
each
page
(Preferably
A4).
iii. When
done,
take
a
picture
of
your
work.
(You
can
use
Microsoft
Office
Lens
mobile
app
to
assist
you).
iv. Submit
your
work
by
uploading
the
pictures.
v. Follow
the
training
manuals
for
assistance.