All pastes #1981224 Raw Edit

Stuff

public c v1 · immutable
#1981224 ·published 2010-11-04 02:46 UTC
rendered paste body
/*    This program written by:    Zachary Easterbrook    Date: 27-10-2010    Lecture: 60-140-1    Lab: 60-140-52    Student ID: 103163420    I confirm that I will keep the content of this assignment/examination confidential.    I confirm that I have not received any unauthorized assistance in preparing for or    doing this assignment/examination. I confirm knowing that a mark of 0 may be assigned    for copied work.*/#include <stdio.h>#include <math.h>// I felt like doing this.#define PI 3.142// Function prototypesdouble WasherWeight(double, double, double, double, double *);double CircleArea(double, double, double *);void PrintWeights(int *, double *, double *, double *);int main(){	int qnt1, qnt2, qnt3, qnt4;	double thick1, thick2, thick3, thick4;	double inner_d1, inner_d2, inner_d3, inner_d4;	double outer_d1, outer_d2, outer_d3, outer_d4;	double density1, density2, density3, density4;		// These variables will hold our circle area info	double area1, area2, area3, area4;		// These variables will hold our weight results	double weight1, weight2, weight3, weight4, total_weight;		printf("Enter the quantity, thickness, density, inner diameter, and outer diameter of Washer Type A :\n");	scanf("%d %lf %lf %lf %lf", &qnt1, &thick1, &density1, &inner_d1, &outer_d1);	printf("Enter the same for type B : \n");	scanf("%d %lf %lf %lf %lf", &qnt2, &thick2, &density2, &inner_d2, &outer_d2);	printf("Enter the same for type C : \n");	scanf("%d %lf %lf %lf %lf", &qnt3, &thick3, &density3, &inner_d3, &outer_d3);	printf("Enter the same for type D : \n");	scanf("%d %lf %lf %lf %lf", &qnt4, &thick4, &density4, &inner_d4, &outer_d4);	// Computer the areas	CircleArea(inner_d1, outer_d1, &area1);	CircleArea(inner_d2, outer_d2, &area2);	CircleArea(inner_d3, outer_d3, &area3);	CircleArea(inner_d4, outer_d4, &area4);	// Get the weights	WasherWeight(qnt1, area1, thick1, density1, &weight1);		WasherWeight(qnt2, area2, thick2, density2, &weight2);		WasherWeight(qnt3, area3, thick3, density3, &weight3);		WasherWeight(qnt4, area4, thick4, density4, &weight4);	total_weight = weight1 + weight2 + weight3 + weight4;		printf("WasherType\tQty\tThickness   Density\tWeight\n");	printf("A\t");		PrintWeights(&qnt1, &thick1, &density1, &weight1);	printf("B\t");	PrintWeights(&qnt2, &thick2, &density2, &weight2);	printf("C\t");	PrintWeights(&qnt3, &thick3, &density3, &weight3);	printf("D\t");	PrintWeights(&qnt4, &thick4, &density4, &weight4);	printf("*********************************************** %.2lf\n", total_weight);}double CircleArea(double inner, double outer, double *area){	double outer_area;	double inner_area;	outer_area = pow((outer / 2), 2) * PI;	inner_area = pow((inner / 2), 2) * PI;	*area = outer_area - inner_area;}double WasherWeight(double quantity, double area, double thickness, double density, double *weight){	*weight = area * thickness * density * quantity;}void PrintWeights(int *quantity, double *thickness, double *density, double *weight){	printf("\t%d\t%.2lf\t    %.2lf\t%.2lf\n", *quantity, *thickness, *density, *weight);}