Kevin321888999

lab 5 part C

Apr 23rd, 2022
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <ctype.h>
  4. #define strands 3
  5. #define sides 4
  6.  
  7. double arearectangle(double Length, double Width)
  8. {return Length*Width; }
  9.  
  10. double perimeter (double length, double width){ return 2*(length+width);}
  11.  
  12. double wirelength (double Perimeter){
  13.   return 3*Perimeter;}
  14.  
  15. double post_side (double length){
  16.   return 2*ceil(length/6);}
  17.  
  18. double post_end(double Width){
  19. return 2*ceil(Width/6);}
  20.  
  21. double posts (double post_side, double post_end){
  22.   return post_side+post_end-4;
  23. }
  24.  
  25.  
  26.  
  27.  
  28. void banner(void){
  29.   printf("-----------------------\n");
  30.   printf("Malachi Sor\nCSCI 1110\n");
  31.   printf("-----------------------\n");
  32.   }
  33.  
  34. int main(void) {
  35.   banner();
  36.   long double area;
  37.   double length;
  38.   double width;
  39.   long double distance;
  40.   double totallength;
  41.   double lengthofwire;
  42.   double dimensions;
  43.   int cornerposts=4;
  44.   int number;
  45.   double ordinaryposts;
  46.   int sideposts;
  47.   int endposts;
  48.  
  49. for(;;){
  50.   printf("\nLength and Width of field feet: ");
  51.   scanf("%lg",&length);
  52.   scanf("%lg",&width);
  53.  
  54. if (length>=20&&length<=1000){
  55.   if(width>=20&&width<=1000){
  56.   printf("Field is %lg ft by %lg ft.", length,width);
  57. sideposts= post_side (length);
  58. endposts=post_end(width);
  59. ordinaryposts=posts(sideposts,endposts);
  60. totallength=perimeter(length,width);
  61. lengthofwire=wirelength(totallength);
  62.  
  63. printf(" We need: \n%i cornerposts\n%lg ordinary posts\n%lg feet of barbed wire",cornerposts,ordinaryposts,lengthofwire);}
  64. else{break;}}
  65. else{printf("Error dimensions must be between 20 and 1000.");}
  66.  
  67. printf("\nEnter '1'to continue or '0' to stop: ");
  68. scanf("%i",&number);
  69. printf("---------------------------------------\n");
  70.  
  71. if (number==0){break;} if(number==1 ){}
  72. }
  73.   return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment