/*
This assignment represents my own work


The following people assisted me with this assignment:

I assisted the following people on this project:

Title: Assignment 1 C Source
Sub-Title: Angles, Lengths and Volumes for a Pier
Course Code: ENG1D04
Tutorial: T25
Submitted By: Gabriel Devenyi
Student ID: 0249371
Date: January 23, 2003
Description: This program inputs some dimensions and distances for a pier and calculates the length of the pier, the volume of its supports and the angle of declanation between it and the sea-floor.

<Asymptions>
1. All input is valid (positive real numbers)
*/

/* Includes */
#include <stdio.h>
#include <math.h>

/* Constants */
#define PI 3.1415
#define RAD_TO_DEG 180/3.1415

int main(void)
{
	/* Variables */
	double ship_distance, ship_depth, pillar_diameter, pillar_clearance, pillar_depth;
	double seafloor_angle, pier_length, pillar_height, pillar_volume;
	
	/* Input */
	printf("Please enter the distance from the shore to the ship: ");
	scanf("%lf", &ship_distance);
	printf("Please enter the depth the ship measures: ");
	scanf("%lf", &ship_depth);
	printf("Please enter the diameter of the pillar: ");
	scanf("%lf", &pillar_diameter);
	printf("Please enter the clearance of the pillar out of water: ");
	scanf("%lf", &pillar_clearance);
	printf("Please enter the depth to which the pillar reaches: ");
	scanf("%lf", &pillar_depth);
	
	/* Calculations */
	seafloor_angle = atan(ship_depth / ship_distance);
	pier_length = pillar_depth / tan(seafloor_angle);
	pillar_height = pillar_depth + pillar_clearance;
	pillar_volume = (PI * pow((pillar_diameter / 2),2) * pillar_height) * 2; /* 2 Pillars */
	seafloor_angle = seafloor_angle * RAD_TO_DEG; /* Computes Radians, convert to degrees */
	
	/* Output */
	printf("\nThe angle between the pier and the sea floor is %.2f degrees.\n", seafloor_angle);
	printf("The length of the pier is %.2f m.\n", pier_length);
	printf("The height of each pillar is %.2f m.\n", pillar_height);
	printf("The total volume of the two pillars is %.2f m^3.\n", pillar_volume);
	
	return 0;
}
	
	
