Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- double calculateAera();
- double calculatePaint();
- double calculatePaintRounded();
- void main() {
- double totalArea = 0;
- //Calculate Wall Area
- int moreWalls = 1;
- double height = 0, width = 0;
- char moreWall[50];
- while (moreWalls == 1) {
- printf("Enter Wall Height (m): ");
- scanf("%lf", &height);
- printf("\nEnter Wall Width (m): ");
- scanf("%lf", &width);
- totalArea += calculateAera(height, width);
- printf("\nMore Walls? (y/n):");
- scanf("%s", moreWall);
- if (moreWall[0] == 110) {
- moreWalls = 0;
- }
- printf("\n");
- }
- printf("\nTotal Wall Area = %lf", totalArea);
- //Calculate Door Area
- int doorAmmount = 0;
- printf("\nHow many doors are there in the room? (count a double door as 2): ");
- scanf("%d", &doorAmmount);
- totalArea -= 2.5 * doorAmmount;
- printf("\nTotal Wall Area = %lf", totalArea);
- //Calculate Widnow Area
- int anyWindows = 1;
- char anyWindow[50];
- double windowHeight = 0, windowWidth = 0;
- printf("\nAny windows (y/n)?: ");
- scanf("%s", anyWindow);
- if (anyWindow[0] == 110) {
- anyWindows = 0;
- }
- while (anyWindows == 1) {
- printf("Enter Wall Height (m): ");
- scanf("%lf", &windowHeight);
- printf("\nEnter Wall Width (m): ");
- scanf("%lf", &windowWidth);
- totalArea -= calculateAera(windowHeight, windowWidth);
- printf("\nAny more windows (y/n)?: ");
- scanf("%s", anyWindow);
- if (anyWindow[0] == 110) {
- anyWindows = 0;
- }
- }
- printf("\nTotal Wall Area = %lf", totalArea);
- //Calculate Paint
- double paintCoverage = 0;
- printf("\nWhat is the coverage in m2 per liter of your paint?: ");
- scanf("%lf", &paintCoverage);
- int coatAmmount = 0;
- printf("\nHow many coats do you want?: ");
- scanf("%d", &coatAmmount);
- double paintAmmount = calculatePaint(totalArea, coatAmmount, paintCoverage);
- printf("\nYou will need %lf or %lf to the nearest litre of paint", paintAmmount, round(paintAmmount));
- }
- double calculateAera(double height, double width) {
- return(height * width);
- };
- double calculatePaint(double area, int numCoats, double m2PerLitre) {
- return(area / (m2PerLitre / numCoats));
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement