Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4.  
  5. double calculateAera();
  6. double calculatePaint();
  7. double calculatePaintRounded();
  8.  
  9. void main() {
  10. double totalArea = 0;
  11.  
  12. //Calculate Wall Area
  13. int moreWalls = 1;
  14. double height = 0, width = 0;
  15. char moreWall[50];
  16. while (moreWalls == 1) {
  17. printf("Enter Wall Height (m): ");
  18. scanf("%lf", &height);
  19.  
  20. printf("\nEnter Wall Width (m): ");
  21. scanf("%lf", &width);
  22. totalArea += calculateAera(height, width);
  23.  
  24. printf("\nMore Walls? (y/n):");
  25. scanf("%s", moreWall);
  26. if (moreWall[0] == 110) {
  27. moreWalls = 0;
  28. }
  29. printf("\n");
  30. }
  31.  
  32. printf("\nTotal Wall Area = %lf", totalArea);
  33.  
  34. //Calculate Door Area
  35. int doorAmmount = 0;
  36. printf("\nHow many doors are there in the room? (count a double door as 2): ");
  37. scanf("%d", &doorAmmount);
  38. totalArea -= 2.5 * doorAmmount;
  39. printf("\nTotal Wall Area = %lf", totalArea);
  40.  
  41. //Calculate Widnow Area
  42. int anyWindows = 1;
  43. char anyWindow[50];
  44.  
  45. double windowHeight = 0, windowWidth = 0;
  46. printf("\nAny windows (y/n)?: ");
  47. scanf("%s", anyWindow);
  48.  
  49. if (anyWindow[0] == 110) {
  50. anyWindows = 0;
  51. }
  52. while (anyWindows == 1) {
  53. printf("Enter Wall Height (m): ");
  54. scanf("%lf", &windowHeight);
  55.  
  56. printf("\nEnter Wall Width (m): ");
  57. scanf("%lf", &windowWidth);
  58. totalArea -= calculateAera(windowHeight, windowWidth);
  59.  
  60. printf("\nAny more windows (y/n)?: ");
  61. scanf("%s", anyWindow);
  62. if (anyWindow[0] == 110) {
  63. anyWindows = 0;
  64. }
  65. }
  66. printf("\nTotal Wall Area = %lf", totalArea);
  67.  
  68. //Calculate Paint
  69. double paintCoverage = 0;
  70. printf("\nWhat is the coverage in m2 per liter of your paint?: ");
  71. scanf("%lf", &paintCoverage);
  72.  
  73. int coatAmmount = 0;
  74. printf("\nHow many coats do you want?: ");
  75. scanf("%d", &coatAmmount);
  76.  
  77. double paintAmmount = calculatePaint(totalArea, coatAmmount, paintCoverage);
  78. printf("\nYou will need %lf or %lf to the nearest litre of paint", paintAmmount, round(paintAmmount));
  79.  
  80. }
  81.  
  82. double calculateAera(double height, double width) {
  83. return(height * width);
  84. };
  85. double calculatePaint(double area, int numCoats, double m2PerLitre) {
  86. return(area / (m2PerLitre / numCoats));
  87. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement