# publicKhan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

file 106 lines (101 sloc) 6.823 kb
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 `        Rate problems 1

vehicle(1)            vehicle(2)                            function(vehicletype) {                    if (vehicletype === "bike") {                        return randRange(5, 15);                    } else if (vehicletype ==="horse") {                        return randRange(3, 30);                    } else if (vehicletype ==="train") {                        return randRange(30, 70);                    } else {                        return randRange(10, 65);                    }                }                        REASONABLESPEED(VEHC1)            REASONABLESPEED(VEHC2)            SPEED1 < SPEED2 ? randRange(SPEED1 + 1, SPEED2 - 1) : randRange(SPEED2 + 1, SPEED1 - 1)            randRange(1, 9)            AVG * TIME            (SPEED1 * SPEED2 * TIME - DIST * SPEED2) / (SPEED1 - SPEED2)            DIST - DIST2

person(1) traveled by VEHC1 at an average speed of SPEED1 miles per hour.

Then, he(1) traveled by VEHC2 at an average speed of SPEED2 miles per hour.

In total, he(1) traveled DIST miles for plural(TIME, "hour").

How many miles did person(1) travel by VEHC1? (Round to the nearest mile.)

round(DIST1) miles

d_vehicleVar(1) = round(DIST1) miles

How many miles did person(1) travel by vehicle(2)? (Round to the nearest mile.)

round(DIST2) miles

d_vehicleVar(2) = round(DIST2) miles

How many minutes did person(1) travel by vehicle(1)? (Round to the nearest minute.)

round(DIST1 / SPEED1 * 60) minutes

t_vehicleVar(1) = round(DIST1 / SPEED1 * 60) minutes

How many minutes did person(1) travel by vehicle(2)? (Round to the nearest minute.)

round(DIST2 / SPEED2 * 60) minutes

t_vehicleVar(2) = round(DIST2 / SPEED2 * 60) minutes

Remember that d = r * t, or written another way, t = d / r.

d_vehicleVar(1) = distance that person(1) traveled by vehicle(1)

d_vehicleVar(2) = distance that person(1) traveled by vehicle(2)

Total distance: d_vehicleVar(1) + d_vehicleVar(2) = DIST

Total time: t_vehicleVar(1) + t_vehicleVar(2) = TIME

t_vehicleVar(1) = (d_vehicleVar(1) / SPEED1) and                t_vehicleVar(2) = (d_vehicleVar(2) / SPEED2)

Substitute the blue equations for:                (d_vehicleVar(1) / SPEED1) + (d_vehicleVar(2) / SPEED2) = TIME

Multiply the above equation by -1 * SPEED1:                -d_vehicleVar(1) - (SPEED1 / SPEED2) * d_vehicleVar(2) = -SPEED1 * TIME

Add the two orange equations for:                (SPEED2 - SPEED1 / SPEED2) * d_vehicleVar(2) = DIST - (SPEED1 * TIME)

Calculating all variables (and then rounding to the nearest integer):
d_vehicleVar(2) = roundTo( 4 , DIST2 ) (round(DIST2)) miles
d_vehicleVar(1) = roundTo( 4 , DIST1 ) (round(DIST1)) miles
t_vehicleVar(1) = roundTo( 4 , DIST1 / SPEED1 * 60 ) (round(DIST1 / SPEED1 * 60)) minutes
t_vehicleVar(2) = roundTo( 4 , DIST2 / SPEED2 * 60 ) (round(DIST2 / SPEED2 * 60)) minutes

`
Something went wrong with that request. Please try again.