Goals

The goal of this assignment is to learn the following:

Computer Science Principles Curriculum

Common Core Standards

Overview

In this assignment, you will write a program to compute the average of the distance a mouse runs during trials in an experiment. The experiment data is provided to calculate the average distance in terms of yards. In addition, you will write code to convert yards to different units of measurement. Create a new project and name it Assignment2_2.

Goal 1: Use a table to write math calculations

An experiment was conducted to determine how far a mouse could run before encountering roadblocks or becoming exhausted. Six trials were conducted. The results of the experiment are shown in the table below:

TrialsDistance (yards)
198.2
285.4
376.7
464.4
589.9
682.5

Your program should add all of the trial distances together and compute the average distance in yards. The average is then converted into different measurement units. The table below shows the conversion of the yard into various units.

UnitsCentimeters (cm)Feet (ft)Inches (in)Meters (m)Miles (mi)
Yard (yd)91.443360.91441/1760

Example: Find the average distance in yards.

number totalDistance = 98.2 + 85.4 + 76.7 + 64.4 + 89.9 + 82.5
number aveYards = totalDistance/6
output aveYards

After you run the example you should have in the output window the number 82.85.

(centimeters, feet, inches, meters, and miles)

Goal 2: Use the Math library to create an object and round numbers


Example: Round answers to the nearest tenth.

Use the example code below to create a Math object. Then use the Round action to round each answer to the nearest tenth. The number after the "," is the number of decimal places you want the answer rounded to.

use Libraries.Compute.Math
Math math
number totalDistance = 98.2 + 85.4 + 76.7 + 64.4 + 89.9 + 82.5
number aveYards = math:Round(totalDistance/6, 1)
output aveYards

After you run the example you should have in the output window the number 82.9.


Next Tutorial

In the next tutorial, we will discuss Assignment 2.3, which describes how work Audio Racing in Quorum..