/****************************************************************************
 * Program: lab2_PL_1.c
 *
 * Author: Jay Fournier
 *
 * Date: 9/14/06
 *
 * Description: This program will integrate the area under the function
 * f(t) = 5t + (sin(9t-5)) / t
 *
 ****************************************************************************/
#include <stdio.h>
#include <math.h>

int main(void)
{

	double start;     	//variable for start point of evaluation
	double end;       	//variable for end point of evaluation
	int step;         	//variable for number of steps
	int i;                  //looping variable
	double width;           //variable for width of section
	double area = 0.0;      //output variable for solution 

	//Give user prompts
	printf("Please enter start point:  ");
	scanf("%lf", &start);

	//test for logical start and end points
	do{
	printf("\n\nPlease enter end point:  ");
	scanf("%lf", &end);
	}
	while(end<start);
	
	printf("\n\nPlease enter number of steps:  ");
	scanf("%d", &step);

	//calculate width of rectangle to use for integration
	width = (end - start) / step;
	

	//loop the rectangle additions 
	for(i = start; i <= end; i += width)
	{
		area = area + ((5 * i) + ((sin((9*i)-5)/i)));
	}

	
	//Print result/solution to user
	printf("\n\nThe solution to the integral with your respective steps, start and end points is %lf"
			, area);

	return(0);

}
