Assignment 2.2: Math

Goals

The goal of this assignment is to learn the following:

  • Use a table to write math calculations
  • Use the Math library to create an object and round numbers

Computer Science Principles Curriculum

  • Big Idea: Data and Information: EK 3.1.1A, EK 3.1.1B, EK 3.1.1D, EK 3.1.1E, EK 3.1.2A, EK 3.1.2B, EK 3.1.2C, EK 3.1.2D, EK 3.1.2E, EK 3.1.2F, EK 3.2.1A, EK 3.2.1B, EK 3.2.1C, EK 3.2.1F, EK 3.2.2A, EK 3.2.2B, EK 3.2.2C, EK 3.2.2G

Common Core Standards

  • English Language Arts Standards » Science & Technical Subjects: CCSS.ELA-Literacy.RST.9-10.2, CCSS.ELA-Literacy.RST.9-10.3, CCSS.ELA-Literacy.RST.9-10.4, CCSS.ELA-Literacy.RST.9-10.5, CCSS.ELA-Literacy.RST.9-10.7, CCSS.ELA-Literacy.RST.9-10.10, CCSS.ELA-Literacy.RST.11-12.2, CCSS.ELA-Literacy.RST.11-12.3, CCSS.ELA-Literacy.RST.11-12.4, CCSS.ELA-Literacy.RST.11-12.5
  • Mathematics Content: High School Number and Quantity » Quantities: CCSS.Math.Content.HSN.Q.1, CCSS.Math.Content.HSN.Q.2, CCSS.Math.Content.HSN.Q.3
  • Mathematics Content: High School Algebra » Seeing Structure in Exoressons: CCSS.Math.Content.HSA.SEE.4
  • Standards For Mathmatical Practice: CCSS.Math.Practice.MP1, CCSS.Math.Practice.MP2, CCSS.Math.Practice.MP4, CCSS.Math.Practice.MP5, CCSS.Math.Practice.MP6, CCSS.Math.Practice.MP7, CCSS.Math.Practice.MP8

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:

Trials and Distance
Trials Distance (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.

Unit Conversion
Units Centimeters (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.

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

  • Round each result to the nearest tenth. For this, you will need to use the Math library. The Math library requires the following use statement:
    use Libraries.Compute.Math

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 Getting Started, which describes how to get started programming in Quorum.