Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to compute the diameter in centimeters of a steel rod, an alumin

ID: 3627919 • Letter: W

Question

Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, 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 rod=compression load/allowable compression stress
area = Pi * r2 where diameter d=2r

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 #include //for sqrt function //declare constants const int STEEL_COMPRESSION = 25000; const int AL_COMPRESSION = 15000; const int COPPER_COMPRESSION = 20000; const float pi = 3.14; int main() { int choice; int compressionLoad; float area; float radius; float diameter; //ask user for metal choice and validate the user choice printf("1. Steel 2. Aluminium 3.Copper "); do{ printf("Select the metal(1,2,or 3) : "); scanf("%d",&choice); }while(choice3); //ask user for comression load printf("Enter Compression Load : "); scanf("%d",&compressionLoad); //calculate area according to metal switch(choice) { case 1: area=compressionLoad/STEEL_COMPRESSION; break; case 2: area=compressionLoad/AL_COMPRESSION; break; case 3: area=compressionLoad/COPPER_COMPRESSION; break; } radius=sqrt(area/pi); radius = radius * 100; //convert radius into centimeter diameter = 2 * radius; //calculate diameter if(choice==1) printf(" Steel %d %d %1f",compressionLoad,STEEL_COMPRESSION,diameter); else if(choice==2) printf(" Aluminium %d %d %1f",compressionLoad,AL_COMPRESSION,diameter); else printf(" Copper%d %d %1f",compressionLoad,COPPER_COMPRESSION,diameter); printf(" "); return 0; } if you can not see clearly. Please click this link http://pastebin.com/raw.php?i=eF0F4tfv
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote