Moment of inertia of a rectangle

You are a civil engineer who wants to create a program to
automatically calculate moments of inertia for common
cross-sections. Table 1 shows three common moments of inertia. In the script file, perform the following tasks:
− Prompt the user for the shape (i.e., ‘R’, ‘H’, ‘C’). HINT: Use a
switch/case structure for this decision.
− Display an error message stating the available options and end
the program if the user does not enter a valid choice.
− Prompt the user for the axis of the moment of inertia (i.e., 1
for xx, 2 for yy) for the rectangle and hollow rectangular
section.
− Prompt the user for the appropriate inputs
− Calculate the moment of inertia
− Print the section shape, moment of inertia, dimensions
corresponding to Figure 1, and axis (where appropriate) about which
the moment of inertia is being calculated clearly labeled and with
proper units to the command window. You are a civil engineer who wants to create a program to
automatically calculate moments of inertia for common
cross-sections. Table 1 shows three common moments of inertia.
In the script file, perform the following tasks:
− Prompt the user for the shape (i.e., ‘R’, ‘H’, ‘C’). HINT: Use a
switch/case structure for this decision.
− Display an error message stating the available options and end
the program if the user does not enter a valid choice.
− Prompt the user for the axis of the moment of inertia (i.e., 1
for xx, 2 for yy) for the rectangle and hollow rectangular
section.
− Prompt the user for the appropriate inputs
− Calculate the moment of inertia
− Print the section shape, moment of inertia, dimensions
corresponding to Figure 1, and axis (where appropriate) about which
the moment of inertia is being calculated clearly labeled and with
proper units to the command window.

Table 1: Bacteria Count Classification Bacteria Classification Surface Area Covered by Bacteria (in2) Low X 2.5 Medium-Low 2.5 XS45 Medium 4.5 x 6.5 High High 6.5 8.5 8.33 Table 1: Bacteria Count Classification Bacteria Classification Surface Area Covered by Bacteria (in2) Low X 2.5 Medium-Low 2.5 XS45 Medium 4.5 x 6.5 High High 6.5 8.5 8.33

Dear Student,
Here is the program..
NOTE: Please note that the following program has been
tested on ubuntu 14.04 system and compiled under gcc
compiler.
————————————————————————————————————————————-
program…
————————————————————————————————————————————
//Header file declaration
#include
#include
#include //starting of main function
int main()
{
//Varibale data type declaration
char code;
float b, d,b1,d1, Ixx, Iyy;
char axis;
printf(“Please enter the Shape code: “);
float PI = 3.14;
scanf(“%c”,&code);
//switch to selected code
switch(code)
{
//Case R
case ‘R’:
printf(“Please enter the axis: “);
scanf(” %c”,&axis);
if(axis == ‘x’)
{
printf(“PLease enter the value of dimension b: “);
scanf(“%f”,&b);
printf(“PLease enter the value of dimesion d: “);
scanf(“%f”,&d);
Ixx = (b * pow(d, 3))/12;
printf(“Section Shape is Rectangle.n”);
printf(“Dimesion b is : %0.2fn”,b);
printf(“Dimesion d is : %0.2fn”,d);
printf(“Axis = xxn”);
printf(“Moment of Inertia is: %0.2fn”,Ixx);
}
else if(axis == ‘y’)
{
printf(“PLease enter the value of dimension d: “);
scanf(“%f”,&d);
printf(“PLease enter the value of dimesion b: “);
scanf(“%f”,&b);
//Calculate Moment of Inertia
Iyy = (d * pow(b, 3))/12;
//Display Information
printf(“Section Shape is Rectangle.n”);
printf(“Dimesion d is : %0.2fn”,d);
printf(“Dimesion b is : %0.2fn”,b);
printf(“Axis = yyn”);
printf(“Moment of Inertia is: %0.2fn”,Iyy);
}
break;
//Case H
case ‘H’:
printf(“Please enter the axis: “);
scanf(” %c”,&axis);
if(axis == ‘x’)
{
printf(“PLease enter the value of dimension b: “);
scanf(“%f”,&b);
printf(“PLease enter the value of dimesion d: “);
scanf(“%f”,&d);
printf(“PLease enter the value of dimension b1: “);
scanf(“%f”,&b1);
printf(“PLease enter the value of dimesion d1: “);
scanf(“%f”,&d1);

Also Read :   Which of the following is not a real Ben & Jerry’s ice cream flavor?

Ixx = (b * pow(d, 3))/12 – (b1 * pow(d1, 3))/12;
printf(“Section Shape is Hollow Rectangular.n”);
printf(“Dimesion b is : %0.2fn”,b);
printf(“Dimesion d is : %0.2fn”,d);
printf(“Dimesion b1 is : %0.2fn”,b1);
printf(“Dimesion d1 is : %0.2fn”,d1);
printf(“Axis = xxn”);
printf(“Moment of Inertia is: %0.2fn”,Ixx);
}
else if(axis == ‘y’)
{
printf(“PLease enter the value of dimension d: “);
scanf(“%f”,&d);
printf(“PLease enter the value of dimesion b: “);
scanf(“%f”,&b);
printf(“PLease enter the value of dimension d1: “);
scanf(“%f”,&d1);
printf(“PLease enter the value of dimesion b1: “);
scanf(“%f”,&b1);

Iyy = (d * pow(b, 3))/12 – (d1 * pow(b1, 3))/12;
printf(“Section Shape is Hollow Rectangular.n”);
printf(“Dimesion d is : %0.2fn”,d);
printf(“Dimesion b is : %0.2fn”,b);
printf(“Dimesion d1 is : %0.2fn”,d1);
printf(“Dimesion b1 is : %0.2fn”,b1);
printf(“Axis = yyn”);
printf(“Moment of Inertia is: %0.2fn”,Iyy);
}
break;
//Case C
case ‘C’:
printf(“Please enter the axis: “);
scanf(” %c”,&axis);
if(axis == ‘x’)
{
printf(“Please enter the value of d: “);
scanf(“%f”, &d);
Ixx = (PI * pow(d,2))*64;
printf(“Shape is = Circlen”);
printf(“Dimesion d is = %fn”, d);
printf(“Axis = xxn”);
printf(“Moment of Inertia is: %0.2fn”,Ixx);
}
else if(axis == ‘y’)
{
printf(“PLease enter the value of d: “);
scanf(“%f”, &d);
Iyy = (PI * pow(d,2))*64;
printf(“Shape is = Circlen”);
printf(“Dimesion d is = %fn”, d);
printf(“Axis = yyn”);
printf(“Moment of Inertia is: %0.2fn”,Iyy);
}
break;
default :
printf(“Invalid input..!. Available options to select are R, H,
Cn”);
break;
}
return 0;
}

Also Read :   Which of the following describes a growth mindset as opposed to a fixed mindset?

————————————————————————————————————————————–
Here i have attached the output of the program as a screen
shot….
Output: Sample run 1
————————————————————————————————————————————-

——————————————————————————————————————————————–
Output: Sample run 2
——————————————————————————————————————————————-

——————————————————————————————————————————————–
Output: Sample run 3
——————————————————————————————————————————————

——————————————————————————————————————————————–
Output: Sample run 4
——————————————————————————————————————————————

———————————————————————————————————————————————
Kindly Check and Verify Thanks…!!!
We were unable to transcribe this image
[email protected]:-/chegg_solutionss gcc monnents_oif inertia.c-m [email protected]:~/chegg_solutionss ./a.out Please enter the Shape code:C Please enter the axis: y PLease enter the value of d: 10 Shape isCircle Dimesion d is10.000000 Axis = yy Moment of Inertia is: 20096.00 nirmalsharmağubuntu:-/chegg_solutionss
[email protected]:-/chegg solutionss gcc momments_oif_inertia.c -lm [email protected]:~/chegg_solutionss ./a.out Please enter the Shape code: X Invalid input..!. Available options to select are R, H, C [email protected]:-/chegg_solutionss
[email protected]:~/chegg solutionss gcc momments oif inertia.c lm [email protected]:~/chegg solutions$ ./a.out Please enter the Shape code: R Please enter the axis: x PLease enter the value of dimension b: 5 PLease enter the value of dimesion d: 6 Section Shape is Rectangle. Dimesion b is : 5.00 Dinesion d is :6.00 Axis- XX Moment of Inertia is: 90.00 nirmalsharmağubuntu:-/chegg_solutionss

Also Read :   che differenza c’è tra provare pena e provare pietà per qualcuno?

Leave a Comment