rendered paste body/* * Name: Philip Lanxon * Collaborator(s): * Instructor: Gary Watson * Date: 10/20/06 * Assignment: pgm3 * Description: Calculate the info given about the pumpkin tossing contest. */#include <stdio.h>#include <stdlib.h>#include <math.h>int main(void) { int year1, distance1, year2, distance2; float range1, range2, time1, time2, theta, meterpersecond1, meterpersecond2, gravity, height1, height2, velocity1, velocity2; /*gravity being the accelleration of gravity, and r being the range */ FILE *fp; fp = fopen("punkindata.txt.", "r"); fscanf(fp, "%d %d %d %d", &year1, &distance1, &year2, &distance2); range1 = distance1; gravity = pow(9.8039 , 2); theta = M_PI/4; /* The acceleration of gravity is 9.8039^2 and 45 degrees is equal to PI/4 */ velocity1 = sqrt(gravity*range1/sin(2*theta)); // equation for velocity time1 = (2*velocity1/gravity)*sin(theta); //equation for time in air height1 = ((pow(velocity1,2))/(2*gravity))*(pow(sin(theta),2)); //equation for height meterpersecond1 = (velocity1)/(3.6); //conversion to meterspersecond range2 = distance2; velocity2 = sqrt(gravity*range2/sin(2*theta)); time2 = (2*velocity2/gravity)*sin(theta); height2 = (pow(velocity2,2)/(2*gravity))*(pow(sin(theta),2)); meterpersecond2 = (velocity2)/(3.6); printf("Results from pumpkin tossing contest!\n\n\n\n"); printf("Year range velocity(m/s) velocity(km/h) time(s) hight(m)\n"); printf("__________________________________________________________________\n"); printf("%d %d %1.2f %1.2f %1.2f %1.2f \n", year1, distance1, meterpersecond1, velocity1, time1, height1); printf("%d %d %1.2f %1.2f %1.2f %1.2f \n", year1, distance2, meterpersecond2, velocity2, time2, height2); getchar(); return 0;}