Question

C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer...

C Language <stdio.h> (FUNCTIONS)

A concrete company wants to estimate what it will cost a customer to have a driveway poured. They can pour

a 3 inch deep 200 sq. ft. driveway in 3 hours, and they charge $50.00 per hour as their labor rate.

Write a program to ask the user for the length of the driveway (in feet), and the width of the driveway (in feet)

to be poured. For both the length and width, make sure the number entered is a non-zero positive number,

and continue to ask the user for the value until a valid number is entered. Then, using 5 different functions,

calculate:

• The square footage of the driveway

• The number of hours required to pour the driveway

• The cost for the concrete to pour the driveway

• The labor charges to pour the driveway

• The total cost to pour the driveway

Create global constants for:

• The number of square feet that can be poured in 3 hours (200)

• The number of hours required to pour 200 sq. ft. (3)

• The labor rate ($50.00/hr.)

• The price for 1 cubic foot of concrete ($90.00)

• Any other numbers used in your program

And, in the function to calculate the cost of the concrete, create a local constant for:

• The number of 3 inch deep square feet in 1 cubic yard of concrete (108)

The program will display:

• The square footage of the driveway

• The number of hours to pour the driveway

• The price for the concrete

• The labor charges

• The total cost to pour the driveway

Hints:

• DO NOT pre-calculate the number of square feet that can be poured in 1 hour – use the 2 constants (of

200 and 3) and let the program calculate the number (in case a new crew is hired that can pour more

than 200 square feet in 3 hours)

• Validation error messages are indented 3 spaces

• Have a blank line between the inputs and the output

• Functions, just as the main() program, should have comments

• Value-returning functions should not get input or display output

• Watch out for integer division

• Don’t forget the function prototypes (if necessary)

• Don’t forget the blank line before ‘Press any key to continue…”

Example Run #1:

(bold type is what is entered by the user)

Enter the length of the driveway (in feet): 80

Enter the width of the driveway (in feet): 8

The square footage of the driveway is: 640.00 sq. ft.

The number of hours required to pour 640.00 square feet is: 9.60 hours

The price for the concrete is: $533.33

The labor charges are: $480.00

The total cost to pour the driveway is: $1013.33

Example Run #2:

Enter the length of the driveway (in feet): -144

A positive value for the length must be entered.

Please re-enter the length of the driveway (in feet): 110

Enter the width of the driveway (in feet): 10

The square footage of the driveway is: 1100.00 sq. ft.

The number of hours required to pour 1100.00 square feet is: 16.50 hours

The price for the concrete is: $916.67

The labor charges are: $825.00

The total cost to pour the driveway is: $1741.67

The example runs show EXACTLY how your program input and output will look.

(validation messages are indented 3 spaces)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

#include<stdio.h>

//Global constants
const float sq_feet=200;
const float hrs=3;
const float rate=50.00;
const float price=90.00;

//Fucntion to calaculate total square feet by multiplying length and width
float calculateSquareFt(float a,float b)
{
   return a*b;
}

//Function to calculate hours taken
float calculateHrs(float Squarefeet)
{
   return (Squarefeet/sq_feet)*hrs;
}

//Function to calculate cost
float calculateCost(float sqft)
{
   const float cubicYard=108;
    return (sqft/cubicYard)*price;
}

//Function to calculate labour cost
float calculateLabour(float hours)
{
   return hours*rate;
}

//Function to calculate total cost
float calculateTotal(float cost,float lcost)
{
   return cost+lcost;
}


void main()
{
   float length,width;   //variables store length and width
   float totalSqft,hrs; //variables to store sq feet of driveway and hours taken to pour concrete
   float cost,labourCost,totalCost; //variables to store cost ,labour cost and total cost
   printf("Enter length of the driveway (in feet): ");
   scanf("%f",&length);
  
   while(length<=0) //Input validation
   {
       printf("   A positive value for the length must be entered. \n");
       printf("   Please re-enter the length of the driveway (in feet): ");
        scanf("%f",&length);  
   }
  
   printf("Enter width of the driveway (in feet): ");
   scanf("%f",&width);
   while(length<=0)   //Input validation
   {
       printf("   A positive value for the width must entered. \n");
       printf("   Please re-enter the width of the driveway (in feet): ");
        scanf("%f",&width);  
   }
  
   totalSqft=calculateSquareFt(length,width);
   hrs=calculateHrs(totalSqft);
   cost=calculateCost(totalSqft);
   labourCost=calculateLabour(hrs);
   totalCost=calculateTotal(cost,labourCost);
  
   printf("\n\nThe square footage of the diveway is: %.2f sq. ft.\n",totalSqft);
   printf("The number of hours required to pour %.2f square feet is: %.2f hours\n",totalSqft,hrs);
   printf("The price for the concrete is: $%.2f\n",cost);
   printf("The labor charges are: $%.2f\n",labourCost);
   printf("The total cost to pour the driveway is: $%.2f\n",totalCost);
      
}

Sample Output:

Add a comment
Know the answer?
Add Answer to:
C Language <stdio.h> (FUNCTIONS) A concrete company wants to estimate what it will cost a customer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is in c programming using functions in visual studios Carpet Jolb A carpeting company wants...

    This is in c programming using functions in visual studios Carpet Jolb A carpeting company wants to estimate what it will cost a customer to have a room carpeted. They can carpet 65 sq. ft. of room space in 4 hours, and they charge $25.00 per hour as their labor rate Write a program to ask the user for the length of the room (in inches) to be carpeted, the width of the room (in inches) to be carpeted, and...

  • C++, please make it as simple as possible. A Paint Company is hiring you to develop...

    C++, please make it as simple as possible. A Paint Company is hiring you to develop an application to estimate the costs for a job. They have determined that for every 120 square feet of wall area, one gallon of paint and eight hours of labor is required. The company charges US$ 18.00 per hour for labor. Write a modular program that allows the user to enter the number of rooms that are to be painted and the price of...

  • Tasks: Complete the following programs noted below: Problem 1: A painting company has determined that for...

    Tasks: Complete the following programs noted below: Problem 1: A painting company has determined that for 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of paint per gallon. The program should display the following data: The use of functions is required....

  • A painting company has determined that for every 110 square feet of wall space, one gallon...

    A painting company has determined that for every 110 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $25.00 per hour for labor. Write a modular program that allows the user to enter the number of rooms that are to be painted (different colors) and the price of the paint per gallon. It should also ask for the square feet of wall space in each room. Rooms and gallons...

  • PLEASE HELP WITH CODE PYTHON BASE.!!!!!!!! Tasks: Complete the following programs noted below: Problem 1: A...

    PLEASE HELP WITH CODE PYTHON BASE.!!!!!!!! Tasks: Complete the following programs noted below: Problem 1: A painting company has determined that for 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of paint per gallon. The program should display the following data:...

  • A painting company has determined that for every 112 square feet of wall space, one gallon...

    A painting company has determined that for every 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon. Use a function (or multiple functions if you want) to calculate the following values - you also need to output...

  • program language: python 3 Purpose: Solve a problem by writing multiple functions that perform different subtasks,...

    program language: python 3 Purpose: Solve a problem by writing multiple functions that perform different subtasks, and combining their use to solve a larger problem. Also to practice documenting functions. Degree of Difficulty: Moderate Your task is to compute the cost of renovating the flooring in a rectangular room. This includes replacing the carpet and and the baseboards. Your task is to write a Python program that calculates and the cost of the renovation. To accomplish this, you will need...

  • A closer look at functions - C++ C option: (The best grade is a 79%) Write...

    A closer look at functions - C++ C option: (The best grade is a 79%) Write a program to calculate the cost and time it takes to fill a swimming pool . Inputs: Length, Width, and Depth of the pool (This is a gross simplification, since pools are not really rectangular cubes.) Fill rate of the pool in Gallons per minute Calculation functions Write a function to calculate the total cubic feet (Length x Width x Depth) and return the...

  • Need to solve this program which will run exactly like sample run .. Thanks Project 2...

    Need to solve this program which will run exactly like sample run .. Thanks Project 2 Using Classes and Objects (Chapter 3) Duc: sec calendar Two files to be submitted: . Algorithm of method main (AlgorithmOfMain.txt, no credit if this is missing) Java Source code (CarpetBill.java- no credit if this has syntax errors) Write a program that creates customers' bills for a carpet company when the information below is given: irst name .Length and width of the carpet in feet...

  • Bullseye Company manufactures dartboards. Its standard cost information follows: Standard Quantity Standard Price (Rate) Standard Unit...

    Bullseye Company manufactures dartboards. Its standard cost information follows: Standard Quantity Standard Price (Rate) Standard Unit Cost Direct materials (cork board) 2.5 sq. ft. $ 2.00 per sq. ft. $ 5.00 Direct labor 1 hrs. $ 14.00 per hr. 14.00 Variable manufacturing overhead (based on direct labor hours) 1 hrs. $ 0.50 per hr. 0.50 Fixed manufacturing overhead ($40,000 ÷ 160,000 units) 0.25 Bullseye has the following actual results for the month of September: Number of units produced and sold...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT