Question

In: Computer Science

needs to be done in C++ Q3. Just just have to code the function and the...

needs to be done in C++

Q3. Just just have to code the function and the function call statement.

This program is for a Carpet Store. Create a function, named CarpetCost, that will have 3 parameters that are float values of length and width and price. The function will return the Total Cost of a piece of Carpet. The values for the Length and the Width is in Feet.   The price of the carpet is in Dollars per Square Yard.

The equation for the Area of the Carpet in Square Feet is: Area_sq_ft = length * width;

The equation for the Area in Carpet in Sqaure Yards is : Area_sq_yd = Area_sq_ft / 9.0;

The equation for the Price of the Carpet in Square Yards is : Price = Area_sq_yd * price;

Example RUN:

Enter the length and width of the Carpet > 5.5 9.5

Enter the price of the carpet in dollar.cents format ($##.##) > = 44.40

Solutions

Expert Solution

FUNCTION TO COMPUTE THE COST OF CARPET

float CarpetCost(float length,float width,float price)
{
    //declare the variables
    float Area_sq_ft,Area_sq_yd,Price;
    //compute the area in square feet
    Area_sq_ft = length * width;
    //compute the area in square yards
    Area_sq_yd = Area_sq_ft/9.0;
    //compute the price of Carpet
    Price = Area_sq_yd * price;
    //return the price
    return(Price);
}

PROGRAMMING IMPLEMENTATION IN C++

#include<iostream>
#include<iomanip>
using namespace std;
float CarpetCost(float length,float width,float price)
{
    //declare the variables
    float Area_sq_ft,Area_sq_yd,Price;
    //compute the area in square feet
    Area_sq_ft = length * width;
    //compute the area in square yards
    Area_sq_yd = Area_sq_ft/9.0;
    //compute the price of Carpet
    Price = Area_sq_yd * price;
    //return the price
    return(Price);
}
//driver program
int main()
{
   //variable declaration
   float length,width,price,cost;
   cout<<endl<<"Enter the length and width of the Carpet > ";
   cin>>length>>width; //read the length and width
   cout<<endl<<"Enter the price of the carpet in dollar,cents format ($##.##) > ";
   cin>>price; //read the price
   //call to CarpetCost()
   cost = CarpetCost(length,width,price);
   cout<<fixed<<setprecision(2);
   //print the carpet cost
   cout<<endl<<"Cost of Carpet : $"<<cost;
}

OUTPUT


Related Solutions

needs to be done in C++ Q6. Coding Question (you must code this problem and submit...
needs to be done in C++ Q6. Coding Question (you must code this problem and submit via Blackboard): Keep everything as Integers. Row and Column Numbering starts at 1. Equation for each Cell :   Coll = (Row * Col * 10) Using Nested Loops display the following exactly as it is shown below:                                  Columns % Brand         1           2         3          4               A            10         20       30       40          B            20         40        60       80           C            30         60        90    ...
C++ Problem. I am providing the code. Just Please provide the new function and highlight it....
C++ Problem. I am providing the code. Just Please provide the new function and highlight it. implement the functions replaceAt, seqSearch, and remove. Test your new function too in main. Also, Test Old functions in main. Show the output. Also, modify the functions accordingly which have "See Programming Exercise 22". main.cpp : #include <iostream> using namespace std; #include "arrayListTypetempl.h" int main(){    arrayListType<int> intList;    arrayListType<char> charList;       intList.insertEnd(5);    intList.insertEnd(3);    intList.insertEnd(4);    intList.insertEnd(55);       charList.insertEnd('a');   ...
MUST BE DONE IN C (NOT C++) Using an array and a function, print the values...
MUST BE DONE IN C (NOT C++) Using an array and a function, print the values of an array backwards. Please follow these guidelines: - Setup your array manually (whichever values you want, as many as you want and whichever datatype you prefer). - Call your function. You should send two parameters to such function: the array’s length and the array. - Inside the function, go ahead and print the array backwards. - Your function shouldn’t return anything
MUST BE DONE IN C (NOT C++) In this task, using a function, we will add...
MUST BE DONE IN C (NOT C++) In this task, using a function, we will add a range of values of an array. The range will be determined by the user. For example, if I have the following array … 1.5 -5.6 8.9 4.6 7.8 995.1 45.1 -5964.2 … and the user tells me to add from the 3rd element to the 6th element, my program would add the values 8.9, 4.6, 7.8 and 995.1. To do so, please follow...
This code needs to be in C++, please. Step 1: Add code to prompt the user...
This code needs to be in C++, please. Step 1: Add code to prompt the user to enter the name of the room that they are entering information for. Validate the input of the name of the room so that an error is shown if the user does not enter a name for the room. The user must be given an unlimited amount of attempts to enter a name for the room. Step 2: Add Input Validation to the code...
Need this in C#. Below is my code for Problem 3 of Assignment 2. Just have...
Need this in C#. Below is my code for Problem 3 of Assignment 2. Just have to add the below requirement of calculating the expected winning probability of VCU. Revisit the program you developed for Problem 3 of Assignment 2. Now your program must calculate the expected winning probability of VCU through simulation. Run the simulation 10,000 times (i.e., play the games 10,000 times) and count the number of wins by VCU. And then, calculate the winning probability by using...
(MUST BE DONE IN C (NOT C++)) In this task, you will have to make sure...
(MUST BE DONE IN C (NOT C++)) In this task, you will have to make sure you understood the concept of “the dot” in programming. Go ahead and declare an array of characters with a default length (whichever length you want, it's fine). Next, you want to ask the user for a phrase and store the characters in your array, but before you do that, ask the user for an estimated length of the array. If the length given is...
Q3)   Write a C program that counts the number of odd numbers with using function count()...
Q3)   Write a C program that counts the number of odd numbers with using function count() within the set. The set has only one negative number which determines the end of set.
C++ Write the C++ code for a void function that prompts the user to enter a...
C++ Write the C++ code for a void function that prompts the user to enter a name, and then stores the user's response in the string variable whose address is passed to the function. Name the function getName.
This problem needs to be solved with source code. I need a C++ program that will...
This problem needs to be solved with source code. I need a C++ program that will help me solve this question. I need it in C++, please. Writing with comments so it maybe cleared. 1.2. We received the following ciphertext which was encoded with a shift cipher: xultpaajcxitltlxaarpjhtiwtgxktghidhipxciwtvgtpilpit ghlxiwiwtxgqadds. 1. Perform an attack against the cipher based on a letter frequency count: How many letters do you have to identify through a frequency count to recover the key? What is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT