Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.25 KB | None | 0 0
  1. #include <stdio.h>
  2. #define SQFT_PER_GALLON 267
  3.  
  4. // Function Prototypes
  5.  
  6. void getMeasurements (int* length, int* width, int* height);
  7. void calcMeasurements(double* squareFootage, double* gallonsOfPaint, int* length, int* width);
  8. int calcSquareFootage(double* squareFootage, int* length, int* width);
  9. double calcGallons(double* squareFootage, double* gallonsOfPaint);
  10. void printOutput(double* squareFootage, double* gallonsOfPaint);
  11.  
  12. int main () {
  13.    
  14.     int length, width, height; // These are the measurements of the wall
  15.     double squareFootage, gallonsOfPaint; // Square Footage needed to paint and gallons of paint needed
  16.    
  17.     getMeasurements(&length, &width, &height);
  18.     calcMeasurements(&squareFootage, &gallonsOfPaint, &length, &width);
  19.     printOutput(&squareFootage, &gallonsOfPaint);
  20.    
  21.     return 0;
  22. } // end main
  23. /***************************************
  24.  
  25.  ****************************************/
  26. void getMeasurements (int* length, int* width, int* height)
  27. {
  28.     printf("Enter the length of the room (whole number only): ");
  29.     scanf("%d", length);
  30.     printf("Enter the width of the room (whole number only): ");
  31.     scanf("%d", width);
  32.     printf("Enter the height of the room (whole number only): ");
  33.     scanf("%d", height);
  34.    
  35.     return;
  36. }
  37. /***************************************
  38.  
  39.  ****************************************/
  40. void calcMeasurements(double* squareFootage, double* gallonsOfPaint, int* length, int* width)
  41. {
  42.     *squareFootage  = calcSquareFootage(squareFootage, length, width);
  43.     *gallonsOfPaint = calcGallons(squareFootage, gallonsOfPaint);
  44.    
  45.     return;
  46. }
  47. /***************************************
  48.  
  49.  ****************************************/
  50. int calcSquareFootage(double* squareFootage, int* length, int* width)
  51. {
  52.     return (*length * *width) * 5;
  53. }
  54. /***************************************
  55.  
  56.  ****************************************/
  57. double calcGallons(double* squareFootage, double* gallonsOfPaint)
  58. {
  59.     return *squareFootage / SQFT_PER_GALLON;
  60. }
  61. /***************************************
  62.  
  63.  ****************************************/
  64. void printOutput(double* squareFootage, double* gallonsOfPaint)
  65. {
  66.     printf("Square Footage to paint: %.lf\n", *squareFootage);
  67.     printf("Gallons of paint needed: %.2lf", *gallonsOfPaint);
  68.    
  69.     return;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement