The goal of this assignment is to learn the following:
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.
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:
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.
|Units||Centimeters (cm)||Feet (ft)||Inches (in)||Meters (m)||Miles (mi)|
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)
Mathlibrary requires the following
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.
In the next tutorial, we will discuss Assignment 2.3, which describes how work Audio Racing in Quorum..