Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exercise 2 Imagine that we’ve a piece of pipe and a rectangular object. Write a program which, given the internal diameter of the pipe and the dimensions.

Similar presentations


Presentation on theme: "Exercise 2 Imagine that we’ve a piece of pipe and a rectangular object. Write a program which, given the internal diameter of the pipe and the dimensions."— Presentation transcript:

1 Exercise 2 Imagine that we’ve a piece of pipe and a rectangular object. Write a program which, given the internal diameter of the pipe and the dimensions (i.e. width, height, and length) of the object, determines whether or not the object can be passed through the pipe. The units used don’t matter as long as they’re consistent (i.e if inches are used, inches must be used throughout). A sample executable has been supplied. Two key points: 1/. Do not assume that length is the biggest dimension. Any of the three dimensions may be the largest. 2/. The object does not have to go through the pipe in any particular orientation. Instead it can be rotated as required. Your program should begin by reading in the diameter of the pipe and the dimensions of the object. If any of these are zero or negative, your program should output an appropriate error message. Otherwise it should determine whether the object can be passed through the pipe and output whether or not it can be. Assume that, if the object is an exact fit for the inside of the pipe, it will pass through the pipe. A useful observation: The biggest dimension of the object doesn’t matter, as this can be aligned with the pipe. It’s the two smaller dimensions that matter. Pipe Object Biggest dimension


Download ppt "Exercise 2 Imagine that we’ve a piece of pipe and a rectangular object. Write a program which, given the internal diameter of the pipe and the dimensions."

Similar presentations


Ads by Google