Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <ctype.h>
- #define strands 3
- #define sides 4
- double arearectangle(double Length, double Width)
- {return Length*Width; }
- double perimeter (double length, double width){ return 2*(length+width);}
- double wirelength (double Perimeter){
- return 3*Perimeter;}
- double post_side (double length){
- return 2*ceil(length/6);}
- double post_end(double Width){
- return 2*ceil(Width/6);}
- double posts (double post_side, double post_end){
- return post_side+post_end-4;
- }
- void banner(void){
- printf("-----------------------\n");
- printf("Malachi Sor\nCSCI 1110\n");
- printf("-----------------------\n");
- }
- int main(void) {
- banner();
- long double area;
- double length;
- double width;
- long double distance;
- double totallength;
- double lengthofwire;
- double dimensions;
- int cornerposts=4;
- int number;
- double ordinaryposts;
- int sideposts;
- int endposts;
- for(;;){
- printf("\nLength and Width of field feet: ");
- scanf("%lg",&length);
- scanf("%lg",&width);
- if (length>=20&&length<=1000){
- if(width>=20&&width<=1000){
- printf("Field is %lg ft by %lg ft.", length,width);
- sideposts= post_side (length);
- endposts=post_end(width);
- ordinaryposts=posts(sideposts,endposts);
- totallength=perimeter(length,width);
- lengthofwire=wirelength(totallength);
- printf(" We need: \n%i cornerposts\n%lg ordinary posts\n%lg feet of barbed wire",cornerposts,ordinaryposts,lengthofwire);}
- else{break;}}
- else{printf("Error dimensions must be between 20 and 1000.");}
- printf("\nEnter '1'to continue or '0' to stop: ");
- scanf("%i",&number);
- printf("---------------------------------------\n");
- if (number==0){break;} if(number==1 ){}
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment