You have decided to replace some of the carpet in your house. Having a limited b
ID: 3878477 • Letter: Y
Question
You have decided to replace some of the carpet in your house. Having a limited budget, you need to first estimate the cost for the various rooms. Instead of doing the calculations by hand, you have decided to put your C++ programming skills to good use and write a program to do the cost estimations. Your program will prompt the user for the needed information then display the calculated values in a neatly formatted report. Use the following information as specifications for your code. Include a heading for your output Prompt the user for the following information: o Name of the room to be carpeted o Length of the room in feet o Width of the room in feet o Price of the carpet per yard o Padding cost Square yardage for a room is calculated by dividing the total square feet by 9. Add 1 yard for any fractional differences. The labor cost of installing the carpet is $6.03/yard Tax rate is currently 5.7% Display the room name in addition to all the above values. 1. Using the parameters above, create a detailed flowchart or pseudocode outlining your program design. Some things to keep in mind while developing your solution: The majority of program development follows the steps of gathering input, perform calculations, then display output. Create a separate list of variables and their data types; variables can be added to the list as you continue developing your solution Start with the basic program flow and add specifics of the program as you further develop the solution 2. From your flowchart or pseudocode, translate each step into C++ code to develop your code. Keep the following points in mind when creating your program: Numeric values should be aligned and formatted to 2 decimal places. Make sure you are using the correct data types for all the values in your program Variable names should be descriptive Code should be indented and contain whitespace. All output should be well labeled. Add a comment to the top of your program that includes your name, the program name, and a description of the program code. Include detailed comments throughout your program.
Explanation / Answer
I have answered this question earlier. Given below is the answer to the question.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int length, width; //dimension of room
string roomName; //name of room to be carpeted
int areaSqft, areaSqYards; //area in square feet and square yards
double carpetPerYard, laborPerYard = 6.03, paddingCost;
double carpetTotal, laborTotal, subTotal, tax, taxRate = 5.7, total;
cout << " Welcome to carpet calculator!" << endl;
cout << "Enter the name of the room to be carpeted: ";
cin >> roomName;
cout << "Enter the length of the room in feet: ";
cin >> length;
cout << "Enter the width of the room in feet: ";
cin >> width;
cout << "Enter the price of the carpet per yard: ";
cin >> carpetPerYard;
cout << "Enter the padding cost: ";
cin >> paddingCost;
areaSqft = length * width;
areaSqYards = (int)(areaSqft / 9.0);
if(areaSqft/9.0 > areaSqYards) //fractional difference, add 1
areaSqYards = areaSqYards + 1;
carpetTotal = carpetPerYard * areaSqYards;
laborTotal = laborPerYard * areaSqYards;
subTotal = carpetTotal + laborTotal + paddingCost;
tax = subTotal * taxRate / 100;
total = subTotal + tax;
cout << fixed << setprecision(2); //display floating point numbers with 2 decimal places
cout << endl << "Carpet estimate for " << roomName << endl;
cout << "Total square feet of the room: " << areaSqft << endl;
cout << "Total square yards of the room: " << areaSqYards << endl;
cout << "Total cost of the carpet needed: " << carpetTotal << endl;
cout << "Total cost of labor (at $6.03/yd): " << laborPerYard << endl;
cout << "Padding Cost: " << paddingCost << endl;
cout << "Subtotal: " << subTotal << endl;
cout << "Tax: " << tax << endl;
cout << "Total: " << total << endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.