Question

In C++ and with an output rounding to 2 decimal places. Carpet Company ABC as been...

In C++ and with an output rounding to 2 decimal places.

Carpet Company ABC as been asked to lay carpet in a mansion that has only triangular rooms. They want a program written that will allow them to enter the three sides of the room and it will calculate the cost of the carpet. The company sells two types of carpet, nylon and polyester. The nylon carpet costs $23 per square yard, while the polyester carpet costs $18 dollars per square yard.

You are to write a program that allows the employee to enter the length of the three sides (in yards), it then computes the area (look up Heron's Formula) and the cost of the carpet of the room. The cost of nylon and polyester should be declared as constants (above main and all capitals) The program ends with a newline.

Note: Points will be deducted (after the due date) if the constants are not declared

Sample Output #1

Enter the length of the first wall (in yards): 8.25
Enter the length of the second wall (in yards): 5.7
Enter the length of the third wall (in yards): 11.8
Enter the type of carpet (N - nylon, P - polyester): N

Receipt
*******
Wall lengths: 8.25, 5.70, and 11.80
Area: 21.431110 square yards
Carpet Type (N-Nylon, P-Polyester): N
Total Cost: $492.92

Sample Output #2

Enter the length of the first wall (in yards): 4.8
Enter the length of the second wall (in yards): 3.7
Enter the length of the third wall (in yards): 4.95
Enter the type of carpet (N - nylon, P - polyester): P

Receipt
*******
Wall lengths: 4.80, 3.70, and 4.95
Area: 8.337261 square yards
Carpet Type (N-Nylon, P-Polyester): P
Total Cost: $150.07
0 0
Add a comment Improve this question Transcribed image text
Answer #1

******************************************************************************************
Please Upvote the answer as it matters to me a lot :)
*****************************************************************************************
As per HomeworkLib expert answering guidelines,Experts are supposed to answer only certain number of questions/sub-parts in a post.Please raise the remaining as a new question as per HomeworkLib guidelines.
******************************************************************************************

#include <bits/stdc++.h>

using namespace std;

int main() {

double first,second , third,total=0;

char carpet;

cout<<"Enter the length of the first wall (in yards):";

cin>>first;

  cout<<"Enter the length of the second wall (in yards):";

cin>>second;

cout<<"Enter the length of the third wall (in yards):";

cin>>third;

cout<<"Carpet Type (N-Nylon, P-Polyester): ";

cin>>carpet;

double s= first+second+third;

s/=2;

double area=sqrt(s*(s-first)*(s- second)*(s- third));

if(carpet=='N')

total = area* 23;

else

total = area* 18;

cout<<fixed<<setprecision(2);

cout<<"Wall lengths: "<<first<<", "<<second<<", and "<<third<<endl;

cout<<"Area: "<<area<<" square yards\n";

cout<<"Carpet Type (N-Nylon, P-Polyester): "<<carpet<<endl;

cout<<"Total cost: $"<<total<<endl;

return 0;

}

Add a comment
Know the answer?
Add Answer to:
In C++ and with an output rounding to 2 decimal places. Carpet Company ABC as been...
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...

  • I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the...

    I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the FeetInches class that is provided in the course Content area on the assignment page for this week. This program will show how classes will interact with each other as data members within another class. Modify the FeetInches class by overloading the following operators which should all return a bool. <= >= != Next add a copy constructor to the FeetInches class and a multiply...

  • 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...

  • 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...

  • 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...

  • Help C++ Design a program for determining how much a fence will cost based on the...

    Help C++ Design a program for determining how much a fence will cost based on the size of a residents back yard. Luckily, every resident has a square backyard with side lengths of at least 6 feet. Unfortunately, there is a local zoning requirement that all fences must be exactly 2 feet inside the perimeter of a backyard. The local fence construction company will charge 10 dollars per foot of fence. Based on the description above design a program that...

  • C++ Lone Star Package Service ships packages within the state of Texas. Packages are accepted for...

    C++ Lone Star Package Service ships packages within the state of Texas. Packages are accepted for shipping subject to the following restrictions: Shipping requirements The package weight must not exceed 50 pounds. The package must not exceed 3 feet in length, width, or height. The girth of the package must not exceed 5 feet. The girth is the circumference around the two smallest sides of the package. If side1, side2, and side3 are the lengths of the three sides, and...

  • Project Objectives: To develop ability to write void and value returning methods and to call them...

    Project Objectives: To develop ability to write void and value returning methods and to call them -- Introduction: Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks (calling the methods) in the correct order. This also allows for efficiencies, since the method can...

  • For this project, you are tasked with creating a text-based, basic String processing program that performs...

    For this project, you are tasked with creating a text-based, basic String processing program that performs basic search on a block of text inputted into your program from an external .txt file. After greeting your end user for a program description, your program should prompt the end user to enter a .txt input filename from which to read the block of text to analyze. Then, prompt the end user for a search String. Next, prompt the end user for the...

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