# Coding Practice¶

A binary number is one that is expressed in the base-2 numeral system.
Write a function `convertToBinary`

which takes a `decimal`

as
a parameter. `convertToBinary`

takes the number in decimal, converts
it into a binary number, and returns the binary number. Test your function
in `main`

. Run and test your code! Select the Parsonsprob tab for hints
for the construction of the code.

A binary number is one that is expressed in the base-2 numeral system.
Write a function `convertToBinary`

which takes a `decimal`

as
a parameter. `convertToBinary`

takes the number in decimal, converts
it into a binary number, and returns the binary number. Test your function
in `main`

. Use the lines to construct the code, then go back to complete
the Activecode tab.

The astronomical start and end dates of the four seasons are based on the position of
the Earth relative to the Sun. As a result, it changes every year and can be difficult to
remember. However, the meteorological start and end dates are based on the Gregorian calendar
and is easier to remember. Spring starts on March 1, summer starts on June 1, fall starts on
September 1, and winter starts on December 1. Write a function called `birthSeason`

, which takes
two parameters, `month`

and `day`

. `birthSeason`

calculates which season
the birthday falls in according to the meteorological start and returns a `string`

with the correct season.
For example, `birthSeason (7, 5)`

returns “summer” since July 5 is in the summer. Select the Parsonsprob tab
for hints for the construction of the code. Run and test your code!

The astronomical start and end dates of the four seasons are based on the position of
the Earth relative to the Sun. As a result, it changes every year and can be difficult to
remember. However, the meteorological start and end dates are based on the Gregorian calendar
and is easier to remember. Spring starts on March 1, summer starts on June 1, fall starts on
September 1, and winter starts on December 1. Write a function called `birthSeason`

, which takes
two parameters, `month`

and `day`

. `birthSeason`

calculates which season
the birthday falls in according to the meteorological start and returns a `string`

with the correct season.
For example, `birthSeason (7, 5)`

returns “summer” since July 5 is in the summer. Use the lines to construct
the code, then go back to complete the Activecode tab.

A number is a common factor of two other numbers if it divides evenly into both of the
other numbers. For example, 2 is a common factor of 4 and 18, because 2 goes evenly into
4 and 18. Write the function `isCommonFactor`

, which takes three parameters,
`num1`

, `num2`

, and `factor`

. `isCommonFactor`

returns `true`

if `factor`

is a
factor of both `num1`

and `num2`

, and returns `false`

otherwise. Run and test your code!
Select the Parsonsprob tab for hints for the construction of the code.

A number is a common factor of two other numbers if it divides evenly into both of the
other numbers. For example, 2 is a common factor of 4 and 18, because 2 goes evenly into
4 and 18. Write the function `isCommonFactor`

, which takes three parameters,
`num1`

, `num2`

, and `factor`

. `isCommonFactor`

returns `true`

if `factor`

is a
factor of both `num1`

and `num2`

, and returns `false`

otherwise. Run and test your code!
Use the lines to construct the code, then go back to complete the Activecode tab.

In the enchanted Mushroom Forest, there are many different types of
mushrooms as far as the eye can see. Most of these mushrooms
can make delicious stews and dishes, but some of them are poisonous.
Write the function `isPoisonous`

, which takes an `char size`

,
`int numSpots`

, and `bool isRed`

as parameters. If a mushroom is large
(‘L’) and has fewer than 3 spots, it is poisonous. If a mushroom is small (‘S’)
and is red, it is poisonous. If a mushroom has fewer than 3 spots or is not red,
it is poisonous. Otherwise, it is not. `isPoisonous`

should return `true`

if
the mushroom is poisonous and `false`

otherwise. Run and test your code!
Select the Parsonsprob tab for hints for the construction of the code.

In the enchanted Mushroom Forest, there are many different types of
mushrooms as far as the eye can see. Most of these mushrooms
can make delicious stews and dishes, but some of them are poisonous.
Write the function `isPoisonous`

, which takes an `char size`

,
`int numSpots`

, and `bool isRed`

as parameters. If a mushroom is large
(‘L’) and has fewer than 3 spots, it is poisonous. If a mushroom is small (‘S’)
and is red, it is poisonous. If a mushroom has fewer than 3 spots or is not red,
it is poisonous. Otherwise, it is not. `isPoisonous`

should return `true`

if
the mushroom is poisonous and `false`

otherwise. Use the lines to construct the
code, then go back to complete the Activecode tab.

Write the function `digitSum`

which takes an `int num`

as a parameter
and returns the sum of all its digits. For example, `digitSum (1423)`

would return 10. Use recursion. Run and test your code! Select the Parsonsprob
tab for hints for the construction of the code.

Write the function `digitSum`

which takes an `int num`

as a parameter
and returns the sum of all its digits. For example, `digitSum (1423)`

would return 10. Use recursion. Use the lines to construct the code, then
go back to complete the Activecode tab.