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

This program has to be written in C language as basic as the guidelines say Prob

ID: 3857817 • Letter: T

Question

This program has to be written in C language as basic as the guidelines say

Problem Statement Your company manufactures electrically conductive metal bars with custom polygonal cross- sections. The metal extrusion machine is limited to producing metal bars with a four-sided polygon as the cross-section. You are given the assignment to calculate the electrical resistance of the bar given its cross-section shape, length, and type of metal Background P3 P4 Pl P2 Arbitrary Cross-section The DC resistance of a conductor having a length L and a uniform cross-sectional area A is given by this equation: where is the electrical conductivity of the conductor. Table 1 shows the conductivity of common metals used in electrical wires. Table 1: Metal electrical conductivity Conductor Silver Copper Gold Aluminum Platinum Conductivity (S/m) 6.30x10 5.96x107 4.10x10 3.50x10 0.943x107

Explanation / Answer

#include<stdio.h>

#include<math.h>

#include <stdlib.h>

double distance(double x1,double x2,double y1,double y2)

{

double d=pow(((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)),.5);

return d;

}

double heron(double a,double b,double c)

{

double s=(a+b+c)/2;

double are=pow((s*(s-a)*(s-b)*(s-c)),.5);

return are;

}

double area(double x3,double x4,double y3,double y4)

{

double x1=6,x2=17,y1=4,y2=4;

double P1P2=distance(x1,x2,y1,y2);

double P1P3=distance(x1,x3,y1,y3);

double P1P4=distance(x1,x4,y1,y4);

double P3P2=distance(x3,x2,y3,y2);

double P3P4=distance(x3,x4,y3,y4);

double T_area=((heron(P1P4,P1P3,P3P4))+(heron(P1P2,P3P2,P1P3)));

return T_area;

}

int ValueCheck(double x3,double x4,double y3, double y4)

{

int i;

if((x3==x4)&&(y3==y4))

{

i=0;

printf(" ERROR: P3 and P4 must be distinct points.");

}

else if((x3<0||x3>25)||((y3<5)||(y3>25)))

{

i=0;

printf(" ERROR: P3 is outside the defined grid space.");

}

else if((x4<0||x4>25)||((y4<5)||(y4>25)))

{

i=0;

printf(" ERROR: P4 is outside the defined grid space.");

}

else if(x3<x4)

{

i=0;

printf(" ERROR:P4 should be strictly to the left of P3.");

}

else if(y3<=4)

{

i=0;

printf(" ERROR:P3 must be above the polygon base.");

}

else if(y4<=4)

{

i=0;

printf(" ERROR:P4 must be above the polygon base.");

}

else

i=1;

return i;

}

double Resistivity(char m)

{

if (m=='S'||m=='s')

return 6.3e+7;

if (m=='C'||m=='c')

return 5.96e+7;

if(m=='G'||m=='g')

return 4.10e+7;

if(m=='A'||m=='a')

return 3.50e+7;

if(m=='P'||m=='p')

return .943e+7;

}

int main()

{

double xP3,xP4,yP3,yP4,a,l,Res,Resistance;

char metal,ch='Y';

while(ch=='Y')

{

int i=0;

printf("Enter x y coordinates of P3 (mm):");

scanf("%lf %lf",&xP3,&yP3);

printf("Enter x y coordinates of P4 (mm):");

scanf("%lf %lf",&xP4,&yP4);

i=ValueCheck(xP3,xP4,yP3,yP4);

if (i==0)

exit(0);

a=area(xP3,xP4,yP3,yP4);

printf(" Total cross-sectional area=%.3e mm^2",a);

printf(" Enter the length of the bar(m):");

scanf("%lf",&l);

if(l<=0)

{

printf(" ERROR: The length of the bar must be a positive number.");

exit(0);

}

printf(" Enter the type of metal(S,C,G,A,P):");

scanf(" %c",&metal);

if((metal!='S'&&metal!='s')&&(metal!='C'&&metal!='c')&&(metal!='G'&&metal!='g')&&(metal!='A'&&metal!='a')&&(metal!='P'&&metal!='p'))

{

printf(" ERROR:That material is not recognized.");

exit(0);

}

Res=Resistivity(metal);

Resistance=l/((Res*a)*1e-6);

printf(" Resistance=%.3e ohms",Resistance);

printf(" Do you want to enter more coordinates?");

scanf(" %c",&ch);

printf(" ");

}

return 0;

}

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