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

I NEED you to tell me the C++ code for these 4 different functions: Function 1:

ID: 3624433 • Letter: I

Question

I NEED you to tell me the C++ code for these 4 different functions:

Function 1: bool isValid( char floorType ): Determines if the floorType is valid. Returns true if it is, false if not.

Function 2: int calculateNumBoxes( int squareFeet ): returns the number of boxes necessary for the parameter squareFeet.

Function 3: void calculateReceipt( char floorType, int numBoxes, double& subtotal, double& tax, double& total, double& downpayment): based upon the floorType and the number of boxes, this function determines the subtotal, tax, total and downpayment.

Function 4: void printReceipt( int numBoxes, double subtotal, double, tax, double total, double downpayment): this function prints the receipt, dollar amounts formatted with exactly 2 digits to the right of the decimal.

The program that I am trying to Implement them to is as follows HOWEVER I don't care about you IMPLEMENTING the code, I just need the functions to be written so they will work with my following program:


#include <iostream>
#include <iomanip>
using namespace std;

const double LAMINATE_RATE = 2.59;
const double ENGINEERED_RATE = 3.19;
const double WOOD_RATE = 3.99;
const double MAX_DOWNPAYMENT = 500.0;
const int SQUARE_FEET_PER_BOX = 30;
const double TAX_RATE = 0.0925;


int main()
{
char floorType; // user inputs of floor type and square feet
int squareFeet;
int numBoxes; // number of boxes user has to buy to cover square feet
double floorRate; // price per square foot

// receipt values for order
double subtotal, tax, total, downpayment;

// set output view
cout.setf( ios::fixed | ios::showpoint );
cout.precision( 2 );

cout << "Welcome to Wood Floors R Us! ";
cout << "To order your flooring, type ";
cout << " L: Laminate ($2.59/sq ft) ";
cout << " E: Engineered hardwood ($3.19/sq ft) ";
cout << " W: Solid wood ($3.99/sq ft) ";
cout << " Q: to quit/exit ";
cout << "Floor type: ";
cin >> floorType;
while( floorType != 'q' && floorType != 'Q')
{
// is floor type invalid?
if ( floorType != 'L' && floorType != 'l' && floorType != 'E' &&
floorType != 'e' && floorType != 'W' && floorType != 'w' )
{
cout << "Invalid floor type. ";
}
else // floor type is valid
{
// get valid square feet > 0
do
{
cout << "Square feet required: ";
cin >> squareFeet;
if ( squareFeet <= 0 )
cout << "square feet must be positive. ";
} while( squareFeet <= 0 );

// how many boxes for that square feet?
numBoxes = squareFeet / 30;
if ( squareFeet % 30 != 0 ) numBoxes++;

// rate determined by floor type
if ( floorType == 'L' || floorType == 'l' )
floorRate = LAMINATE_RATE;
else if ( floorType == 'E' || floorType == 'e' )
floorRate = ENGINEERED_RATE;
else // W or w for solid wood
floorRate = WOOD_RATE;

// calc and print subtotal, taxes, total and downpayment
subtotal = numBoxes * SQUARE_FEET_PER_BOX * floorRate;
tax = subtotal * TAX_RATE;
total = subtotal + tax;
if ( total <= MAX_DOWNPAYMENT )
downpayment = total;
else
downpayment = MAX_DOWNPAYMENT;
cout << "Number of boxes: " << numBoxes;
cout << " Subtotal: $" << subtotal;
cout << " Tax (9.25%): $" << tax;
cout << " Total: $" << total;
cout << " Required downpayment: $" << downpayment << endl;
} // end else valid floor type

// get next order
cout << "To order your flooring, type ";
cout << " L: Laminate ($2.59/sq ft) ";
cout << " E: Engineered hardwood ($3.19/sq ft) ";
cout << " W: Solid wood ($3.99/sq ft) ";
cout << " Q: to quit/exit ";
cout << "Floor type: ";
cin >> floorType;
} // end while user doesn't quit
cout << "Thank you for your patronage ";
} // end of program.


Explanation / Answer

bool isValid( char floorType )

{

    if(floorType =='L' || floorType == 'l' ||

         floorType == 'E'||floorType == 'e' ||

             floorType == 'W' || floorType != 'w' )

          return true;

      else

         return false;

}

{

    int boxes;

      boxes = squareFeet / 30;

     if ( squareFeet % 30 != 0 )

            boxes++;

      return boxes;

void calculateReceipt( char floorType, int numBoxes, double& subtotal,

       double& tax, double& total, double& downpayment)

{  

      double floorRate;

      if ( floorType == 'L' || floorType == 'l' )

        floorRate = LAMINATE_RATE;

      else if ( floorType == 'E' || floorType == 'e' )

        floorRate = ENGINEERED_RATE;

      else // W or w for solid wood

        floorRate = WOOD_RATE;

   tax=9.25*subtotal;

     total=tax+subtotal;

     if ( total <= MAX_DOWNPAYMENT )

        downpayment = total;

     else

      downpayment = MAX_DOWNPAYMENT;

}

   {

     cout << "Number of boxes: " << numBoxes;

     cout << " Subtotal: $" << subtotal;

     cout << " Tax (9.25%): $" << tax;

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