please can some one modify my program its not working the task : a table of the
ID: 3645181 • Letter: P
Question
please can some one modify my program its not workingthe task :
a table of the engineering properties of two materials first one is lumber and second one is wood. The dimensions for both material are given as the base and the height in inches.
The owner makes lumber with base sizes of 2, 6 and 10 inches. The height sizes are 2, 6, 10 and 14 inches. Produce table with appropriate heading to show these values and computed engineering properties.
we will calculate the cross sectional area whic is : base * high * e
but Program should not use build in function pow or exp to calculate power and exponential. Programmer should write his own function my_power, my_expon to calculate them.
the code :
#include <stdio.h>
#include <math.h>
double my_cross_sectional_1(int base, int hight);
double my_cross_sectional_2(int base, int hight);
double moment_of_inertia(int base, int hight);
double section_modulus(int base, int hight);
int main()
{
char m;
int counter, area, inertia, modu, y, z,B,H,first= 2,seconed = 2;
printf("Please choose your material press 1 for lumber or 2 for general wood or Q to end ");
scanf("%c", &m);
printf(" Size Cross sectional area Moment of inertia Section modulus ");
counter = 0;
B = 2;
for ( H = 2;H <= 14 ; H+4 )
{
while (m !='Q'|| m!='q')
{
if (m=='1')
{
printf("Your material is Lumber ");
my_cross_sectional_1( B, H);
moment_of_inertia(B, H);
section_modulus(B, H);
printf("%3d%3d%3d ",counter,y,z);
}
if (m =='2')
{
printf("Your material is general wood ");
my_cross_sectional_2( B, H);
moment_of_inertia(B, H);
section_modulus(B, H);
}
else
printf("Please choose your material press 1 for lumber or 2 for general wood or Q to end ");
}
printf("%d tims %d ",B,H);
if (H = 14)
{
B = B + 4;
H = 2 ;
}
}
return 0;
}
double my_cross_sectional_1( int base, int hight)
{
double y;
y=base*hight;
return(y);
}
double my_cross_sectional_2( int base, int hight)
{
double y;
y=2*base*hight;
return(y);
}
double moment_of_inertia(int base,int hight)
{
double y;
y= ((base*hight*hight*hight)/12);
return(y);
}
double section_modulus(int base, int hight)
{
double y;
y= (base*hight*hight)/6;
return(y);
}
Explanation / Answer
As per your program, we obtain output for the base values, 2,6,10,14,...infinite
Hence we need to make use of the counter variable which is declared as "0" initially.
For base values 2,6,10 we have heights 2,6,10,14,i.e.,after 12 iterations the computation must come to end.
Therefore we need to check if counter value is 12.
#include
#include
double my_cross_sectional_1(int base, int hight);
double my_cross_sectional_2(int base, int hight);
double moment_of_inertia(int base, int hight);
double section_modulus(int base, int hight);
int main()
{
char m;
int counter, area, inertia, modu, y, z,B,H,first= 2,seconed = 2;
printf("Please choose your material press 1 for lumber or 2 for general wood or Q to end ");
scanf("%c", &m);
printf(" Size Cross sectional area Moment of inertia Section modulus ");
counter = 0;
B = 2;
for ( H = 2;H <= 14 ; H+4 )
{
while (m !='Q'|| m!='q' || counter=12)
{
if (m=='1')
{
printf("Your material is Lumber ");
my_cross_sectional_1( B, H);
moment_of_inertia(B, H);
section_modulus(B, H);
printf("%3d%3d%3d ",counter,y,z);
}
if (m =='2')
{
printf("Your material is general wood ");
my_cross_sectional_2( B, H);
moment_of_inertia(B, H);
section_modulus(B, H);
}
else
printf("Please choose your material press 1 for lumber or 2 for general wood or Q to end ");
}
printf("%d tims %d ",B,H);
if (H = 14)
{
B = B + 4;
H = 2 ;
}
counter++;
}
return 0;
}
double my_cross_sectional_1( int base, int hight)
{
double y;
y=base*hight;
return(y);
}
double my_cross_sectional_2( int base, int hight)
{
double y;
y=2*base*hight;
return(y);
}
double moment_of_inertia(int base,int hight)
{
double y;
y= ((base*hight*hight*hight)/12);
return(y);
}
double section_modulus(int base, int hight)
{
double y;
y= (base*hight*hight)/6;
return(y);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.