/* 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 #include // I felt like doing this. #define PI 3.142 // Global input variables 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; // Global output variables double area1, area2, area3, area4; double weight1, weight2, weight3, weight4, total_weight; // Function prototypes double WasherWeight(void); double CircleArea(void); void PrintWeights(void); int main() { 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); CircleArea(); WasherWeight(); total_weight = weight1 + weight2 + weight3 + weight4; PrintWeights(); } double CircleArea(void) { area1 = (pow((outer_d1 / 2), 2) * PI) - (pow((inner_d1 / 2), 2) * PI); area2 = (pow((outer_d2 / 2), 2) * PI) - (pow((inner_d2 / 2), 2) * PI); area3 = (pow((outer_d3 / 2), 2) * PI) - (pow((inner_d3 / 2), 2) * PI); area4 = (pow((outer_d4 / 2), 2) * PI) - (pow((inner_d4 / 2), 2) * PI); } double WasherWeight(void) { weight1 = qnt1 * thick1 * density1 * area1; weight2 = qnt2 * thick2 * density2 * area2; weight3 = qnt3 * thick3 * density3 * area3; weight4 = qnt4 * thick4 * density4 * area4; } void PrintWeights(void) { printf("WasherType\tQty\tThickness Density\tWeight\n"); printf("A\t\t%d\t%.2lf\t %.2lf\t%.2lf\n", qnt1, thick1, density1, weight1); printf("B\t\t%d\t%.2lf\t %.2lf\t%.2lf\n", qnt2, thick2, density2, weight2); printf("C\t\t%d\t%.2lf\t %.2lf\t%.2lf\n", qnt3, thick3, density3, weight3); printf("D\t\t%d\t%.2lf\t %.2lf\t%.2lf\n", qnt4, thick4, density4, weight4); printf("*********************************************** %.2lf\n", total_weight); }