Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SQFT_PER_GALLON 267
- // Function Prototypes
- void getMeasurements (int* length, int* width, int* height);
- void calcMeasurements(double* squareFootage, double* gallonsOfPaint, int* length, int* width);
- int calcSquareFootage(double* squareFootage, int* length, int* width);
- double calcGallons(double* squareFootage, double* gallonsOfPaint);
- void printOutput(double* squareFootage, double* gallonsOfPaint);
- int main () {
- int length, width, height; // These are the measurements of the wall
- double squareFootage, gallonsOfPaint; // Square Footage needed to paint and gallons of paint needed
- getMeasurements(&length, &width, &height);
- calcMeasurements(&squareFootage, &gallonsOfPaint, &length, &width);
- printOutput(&squareFootage, &gallonsOfPaint);
- return 0;
- } // end main
- /***************************************
- ****************************************/
- void getMeasurements (int* length, int* width, int* height)
- {
- printf("Enter the length of the room (whole number only): ");
- scanf("%d", length);
- printf("Enter the width of the room (whole number only): ");
- scanf("%d", width);
- printf("Enter the height of the room (whole number only): ");
- scanf("%d", height);
- return;
- }
- /***************************************
- ****************************************/
- void calcMeasurements(double* squareFootage, double* gallonsOfPaint, int* length, int* width)
- {
- *squareFootage = calcSquareFootage(squareFootage, length, width);
- *gallonsOfPaint = calcGallons(squareFootage, gallonsOfPaint);
- return;
- }
- /***************************************
- ****************************************/
- int calcSquareFootage(double* squareFootage, int* length, int* width)
- {
- return (*length * *width) * 5;
- }
- /***************************************
- ****************************************/
- double calcGallons(double* squareFootage, double* gallonsOfPaint)
- {
- return *squareFootage / SQFT_PER_GALLON;
- }
- /***************************************
- ****************************************/
- void printOutput(double* squareFootage, double* gallonsOfPaint)
- {
- printf("Square Footage to paint: %.lf\n", *squareFootage);
- printf("Gallons of paint needed: %.2lf", *gallonsOfPaint);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement