exercise 1

2
Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 1 Exercise 1 When two railway tracks cross each other “at grade” (at the same level), a piece of track work called a “diamond” is used. The diagram below should give the idea. Track #1 Track #2 Note that, in both directions, there are gaps in the rails When a train goes over a diamond, its wheels drop into these gaps, as shown below. The amount that the wheels drop (X on the diagram) depends on both the diameter of the wheels (D) and the size of the gap (G). D G X

Upload: amethyst-cabrera

Post on 02-Jan-2016

23 views

Category:

Documents


1 download

DESCRIPTION

Track #1. Track #2. D. X. G. Exercise 1. When two railway tracks cross each other “at grade” (at the same level), a piece of track work called a “diamond” is used. The diagram below should give the idea. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Exercise 1

91.166 Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 1

Exercise 1

When two railway tracks cross each other “at grade” (at the same level), a piece of track work called a “diamond” is used. The diagram below should give the idea.

Track #1

Track #2

Note that, in both directions, there are gaps in the rails When a train goes over a diamond, its wheels drop into these gaps, as shown below. The amount that the wheels drop (X on the diagram) depends on both the diameter of the wheels (D) and the size of the gap (G).

D

G

X

Page 2: Exercise 1

91.166 Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 2

You are to write, test, and submit a C++ program which, after reading in values for “D” and “G”, calculates and outputs the value of “X”. “D”, “G”, and “X” are all to be in inches.

The “hard” part of this assignment is coming up with a formula for “X” (strong hint: consider the triangle shown in dotted lines). The actual program is as about basic as they get (no if’s and no loops).

Square roots may be computed by using function “sqrt” (as illustrated by the code snippet below). Note that, in order to use this function, you must put “#include <math.h>” at the start of your program.

#include <math.h>…. double x, y; …. x = sqrt(y); // the square root of the valuie stored in “y” is placed into “x”

Values can be squared using a function called “pow”, but it makes more sense to just multiply a value by itself. There is no “sqr” function.

If you find this assignment a bit boring (as many of you doubtless will), try writing a program which output a table giving the values of “X” for a range of possible wheel sizes. If you wish, you may submit this in place of the standard program.

Wheel Diameter Drop --------------------------------------- 30 … 31 … etc.

Some background: The “O” train passes over two diamonds in between the Confederation and Greenboro stations, and must slow down in both cases. The speed restrictions were imposed because the central two trucks of “O” trains have smaller than standard wheels. These drop more than usual when crossing over diamonds, and Bombardier (the manufacturer) is concerned about possible damage.