Write a program to compute the diameter in centimeters of a steel rod, an alumin
ID: 3538201 • Letter: W
Question
Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rode, which can withstand a particular compression load. The allowable compression stress of steel, aluminum, and copper is 25,000 lbs/m2, 15,000 lbs/m2, and 20,000 lbs/m2, respectively.
Area of load / allowable compression stress
Area = %u03C0 r2 where diameter
Input the compression load. Print the type of material, load, allowable stress, and diameter. Use formatted output with field width specifications that align the output.?
Explanation / Answer
#include 02 #include 03 #include 04 05 const float pi = 3.14; 06 const int aluminum_compression = 15000; 07 const int steel_compression = 25000; 08 const int copper_compression = 20000; 09 10 11 int main() 12 { 13 int load; 14 int userchoice; 15 float area; 16 float radius; 17 float diameter; 18 19 printf(" Please select a metal of your choice:"); 20 printf(" 1 = Steel"); 21 printf(" 2 = Aluminum"); 22 printf(" 3 = Copper"); 23 do{ 24 printf(" Please select 1, 2 or 3 : "); 25 scanf("%d",&userchoice); 26 }while(userchoice3); 27 printf(" Enter The Compression Load : "); 28 scanf("%d",&load); 29 switch(userchoice) 30 { 31 case 1: 32 area=load/steel_compression; 33 break; 34 case 2: 35 area=load/aluminum_compression; 36 break; 37 case 3: 38 area=load/copper_compression; 39 break; 40 } 41 radius = (area/pi); 42 radius = sqrt(radius); 43 radius = radius * 100; //convert radius into centimeter 44 diameter = 2 * radius; //calculate diameter 45 if(userchoice==1) 46 printf(" Metal = Steel, Load = %d, Allowable Compression = %d, Diameter = ",load,steel_compression,diameter); 47 else if(userchoice==2) 48 printf(" Metal = Aluminium, Load = %d, Allowable Compression = %d, Diameter = ",load,aluminum_compression,diameter); 49 else 50 printf(" Metal = Copper, Load = %d, Allowable Compression = %d, Diameter = ",load,copper_compression,diameter); 51 52 getch(); 53 54 return 0; 55 }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.