Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help and I need the code the same as look like the sample run, please A r

ID: 3864010 • Letter: I

Question

I need help and I need the code the same as look like the sample run, please

A remodeling company needs a program to determine the cost of painting a room. Write a C++ program that lets the user enter the length and width of a room in feet as integers, and then calculates the total square footage of the room, the number of cans of paint rounded to the next whole number, and the cost of the paint. The height of the room is 8 feet, and the price of a can of paint is 12.99. A one-gallon can of paint covers 250 square feet.

You do not need to factor in the area for doors and windows, but include the ceiling. There are a number of ways to solve this problem. You may want to check the description for the ceil and floor functions in Display 4.2.

The program should loop until the user enters 0 for length. Use the pretest while structure as you did in Project Two. The loop structure should be part of the main function.

The program includes the following functions: Be sure to use the function names provided. Do not change the specifications for the functions.

displayTitle

This function displays a title for the window. displayTitle is an example of a void function (Section 5.1).

getData

This function displays a prompt requesting the value for the length. If 0 is not entered for the length, the function displays a prompt requesting the width. This function is a call-by-reference since it needs to supply main with two values. Check Display 5.4 get_numbers function and Display 5-9 get_input function. The rest of the functions are call-by-value. Do not use call call-by-reference.

calcSqFt

This function receives the values for length and width, and calculates the square footage including the ceiling. The function returns an integer to main.

calcTotalCans

This function calculates and returns the number of cans needed rounding up to the next whole number.

calcCost

This function calculates and returns the total cost.

displayResults

This function receives the numeric results to display. Note how the decimals are aligned for readability in the sample run.

displayMsg

This function displays a message reporting a free gift based on the number of cans purchased. Be sure to use a nested if.

1 - 3 cans – free paint brush.

4-7 cans – free paint tray.

More than 7 cans – $10 gift card.

Here is a sample run:

ere is a sample run: Chesapeake Reno deling Conpany Paint Costing Enter length in feet Kg to stop 10 Enter width in feet. 12 Square footage 472 Cans Cost 25.98 Thank you for your purchase Gift free paint brush. Enter length in feet CO to stop CSIT 211 Lab 30) doc A Project 1 (4) docx

Explanation / Answer

#include <iostream>
#include <cmath>

using namespace std;

void displayTitle()
{
   cout<<" Chesapeake Remodelling Company";
   cout<<"         Paint Costing         ";
   cout<<" ------------------------------";
}

void getData(int *length,int *width)
{
    cout<<" Enter length in feet <0 to stop>---";
    cin>>*length;
  
   cout<<" Enter width in feet----------------";
   cin>>*width;
}

int calcSqFt(int length,int width)
{
    int area = 2*length*8 + 2*width*8 + length*width; //5 walls including ceiling
    return area;
}
int calcTotalCans(int area)
{
    return (int)(ceil((double)area/250));
}
double calcCost(int cans)
{
    return 12.99 * cans;
  
}
void displayMsg(int cans)
{
    string gift;
    if(cans >=1 && cans <= 3)
    gift = "free paint brush";
    else if(cans >= 4 && cans <= 7)
    gift = "free paint tray";
    else if(cans >7)
    gift = "$10 gift card";
  
    cout<<" Thank you for your purchase";
    cout<<" Free gift = "<<gift;
  
  
}
void displayResults(int area,int cans,double cost)
{
  
    cout<<" Square Footage = "<<area;
    cout<<" Cans           = "<<cans;
    cout<<" Cost           = "<<cost;
}

int main()
{
int length,width,area,cans;
double cost;

   displayTitle();
   do
   {
   getData(&length,&width);
   if(length == 0)
    break;;
   area = calcSqFt(length,width);
   cans = calcTotalCans(area);
   cost = calcCost(cans);
    displayResults(area,cans,cost);
   displayMsg(cans);
   }while(length != 0);

   return 0;
}


Output:

Chesapeake Remodelling Company
           Paint Costing        
------------------------------

Enter length in feet <0 to stop>--- 10
Enter width in feet---------------- 12

Square Footage = 472
Cans                  = 2
Cost                   = 25.98

Thank you for your purchase
    Free gift = free paint brush

Enter length in feet <0 to stop>--- 0
Enter width in feet----------------

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote