Friday, June 8, 2012

Exemplar Question if statements


The SPCA have received advertisements for various dog foods and have to decide whether the foods are acceptable or not, based on the nutritional content. 
The criteria to determine whether the food is acceptable are:
·       There must be more than twice as much protein as moisture and
·       The food must contain more than 1% calcium or more than 0.5% phosphorus and
·       The price per kg must be less than R15/kg

1.     Open the project named Q2.sb in Scratch. 
1.1.   When you click on the button, the program must :
1.1.1.       Ask the user for the percentage protein, moisture, calcium and phosphorus and store the ingredients (protein, moisture, calcium and phosphorus) in 4 variables called protein, moisture, calcium and phosphorus    (8)
1.1.2.       Ask the user for the price per bag and store the value in a variable named pricePerBag                                                                             (2)
1.1.3.       Ask the user for the Size of the bag (kg dog food per bag) and store the value in a variable named sizeKg                                              (2)
1.1.4.       Use the necessary if statement(s) to determine whether the composition of the dog food is acceptable                                                       (11)
1.1.5.       Display a message saying whether the dog food is acceptable      (2)

You can use the following table for test data.                                      

Emerald Gold
Eukanuba
Pedigree Supreme
Crude Protein
20%
26%
21%
Moisture
9%
8%
12%
Calcium
1.2%
0.80%
1%
Phosphorus
0.8%
0.65%
0.5%
Size of bag
20kg
15kg
25kg
Price
R270
R549
R210

acceptable
unacceptable
unacceptable

Solution

No comments:

Post a Comment