All pastes #213064 Raw Edit

Someone

public c v1 · immutable
#213064 ·published 2006-10-21 05:35 UTC
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, dist1, year2, dist2;	float r1, r2, t1, t2, x, ms1, ms2;	double g,h1, v1, h2, v2 ;	// t being time v being velocity, g being the accelleration of gravity, and r being the range		FILE *fp;	fp = fopen("punkindata.txt.", "r");	fscanf(fp, "%d %d %d %d",  &year1,  &dist1, &year2, &dist2);		r1 = dist1;	g = pow(9.8039 , 2);	x = M_PI/4; //45 degrees is equal to PI/4		v1 = sqrt(g*r1/sin(2*x)); //equation for velocity	t1 = (2*v1/g)*sin(x);  //equation for time in air	h1 = ((pow(v1,2))/(2*g))*(pow(sin(x),2)); //equation for hight	ms1 = (v1)/(3.6); //conversion to ms		r2 = dist2;		v2 = sqrt(g*r2/sin(2*x));	t2 = (2*v2/g)*sin(x);	h2 = ((pow(v2,2))/(2*g))*(pow(sin(x),2));	ms2 = (v2)/(3.6);		printf("Results from pumpkin tossing contest!\n\n\n\n");	printf("Year\trange\tvelocity(m/s)\tvelocity(km/h)\ttime(s)\thight(m)\n");	printf("__________________________________________________________________\n");	printf("%d\t%d\t%1.2f\t%1.2f\t%1.2f\t%1.2f\t\n", year1,  dist1, ms1,  v1,  t1, h1);	printf("%d\t%d\t%1.2f\t%1.2f\t%1.2f\t%1.2f\t\n", year1,  dist2, ms2,  v2,  t2, h2);		getchar();		return 0;}