code in C++
Create a program that uses the pass by reference operator instead of the return command.
Your main program will need to: create empty variables
call void function 1 with no input to display your name to the screen
call function 2 to collect the square feet that a gallon of paint covers from user
call function 2 to collect the square feet of wall that needs to be painted
call function 3 to calculate the number of gallons of paint ( round up )
display all of the user input values and all the calculated values with messages inside main after you have completed calling the functions.
Notes:
functions 2, and 3 will use reference variables for the answer, see description below. These functions will both take in two or more variables/arguments/parameters to perform the required calculations.
You should not repeat any calculations.
You should not use by reference operator unless you intend to
change the value of that variable.
NO CALCULATIONS may occur in the main function. NO return
statements are allowed for any of the functions. Functions may
contain constants if reasonable.
All three functions will be void functions
NO global variables and no pointers are allowed.
Grading will be as follows
(5) function 1 - no input, no reference variables, no returned variables
(5) function 2 - takes in a string ( which will be the prompt message ), uses reference variable to get the value entered back to the main program. This function will display the prompt message and ask the user to enter a value, but will not use a return statement. Your program will call this function 2 times from main, sending different prompt messages. The two items you need to collect from the user are: the number of square feet a gallon of paint will cover and the square feet of wall to be painted.
(5) function 3 – takes in two numbers ( the square feet of wall to be painted, and the square feet a gallon of paint will cover) and calculates the number of gallons. Remember to use a round up function ( meaning .5 and higher needs another gallon ) Number of gallons is wall area divided by the square feet a gallon of paint will cover and should be calculated as an integer.
additional points will be awarded based on these considerations when grading include
You should need about three variables in main. Other variables may be created in the other functions but only 3 are probably all that is required.
You should not repeat any calculations.
Prompt for each variable only one time using function 2
Reasonable function names are expected ( NOT function1, function2 ,
etc )
You should not use by reference operator unless you intend to
change the value of that variable.Program must contain a
system(“pause”) statement.
code a second call statement for a bonus of 5 points will be given for using a single call to function 3 nesting the calls to function 2 .
All the explanations is in the code comments. Hope this helps!
Code:
#include <iostream>
#include <cmath>
using namespace std;
// function 1 to print name
void printName()
{
cout << "Chegg" << endl;
}
// function 2 to take user input
// use pointer for pass by reference
void takeInput(string prompt, double* input)
{
cout << prompt << endl;
cin >> *input;
}
// function 3 to calculate number of gallons required
void calculate(double *sqft, double *area, int *gallons)
{
// nesting of function 2 in function 3
takeInput("Enter the number of square feet a gallon of paint will
cover", sqft);
takeInput("Enter the square feet of wall to be painted",
area);
// calculate gallons
//take temperary to store gallons in floating point
double tmp = *area / *sqft;
*gallons = round(tmp);
}
int main()
{
// 3 variables
double sqft, area;
int gallons;
// call function 1 and 3
printName();
calculate(&sqft, &area, &gallons);
// print results
cout << "A gallon of paint will cover " << sqft
<< " square feet\n";
cout << "Area of wall to be painted is " << area
<< " square feet\n";
cout << "Gallons of paint required: " << gallons
<< endl;
return 0;
}
Sample output:
Code screenshots:
code in C++ Create a program that uses the pass by reference operator instead of the...
I need to write a paint job estimator program in python. I have most of it down but i keep getting errors and I dont know how to fix it or what im doing worng specs: A painting company has determined that for every 350 square feet of wall space, one gallon of paint and six hours of labor are required. The company charges $62.25 per hour for labor. Write a program call paintjobestimator.py that asks the user to enter...
PLEASE HELP WITH CODE PYTHON BASE.!!!!!!!! Tasks: Complete the following programs noted below: Problem 1: A painting company has determined that for 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of paint per gallon. The program should display the following data:...
This exercise requires designing a program which solves the problem described in the problem statement below. Provide comments as necessary in your pseudo-code and the Java program. Your solution must include these components: Flowchart Pseudo-code Hierarchy Chart Program Coded Program Output Problem Statement A painting company has determined that to paint 115 square feet of wall space, the task will require one gallon of paint and 8 hours of labor. The company charges $20.00 per hour for labor. Design a...
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...
Tasks: Complete the following programs noted below: Problem 1: A painting company has determined that for 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of paint per gallon. The program should display the following data: The use of functions is required....
A painting company has determined that for every 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon. Use a function (or multiple functions if you want) to calculate the following values - you also need to output...
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...
Hello, I have seen this in Java and C++ but I am trying to learn it in Python ..any help on the code would be great..ThanksPaint job estimatorQuestion DetailsA painting company has determined that for every 115 square feet or wall space, one gallon of paint and eight hours of labor will be required. The company charges$20.00 per hour for labor . Write a program that allows the user to enter the number of rooms to be painted and the...
(1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (Submit for 2 points). Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet (2) Extend to also calculate and output the amount of paint in gallons needed to paint the wall. Assume a gallon of paint covers 350 square feet. Store this value using a const double variable. (Submit for 2 points, so 4 points total). Enter...
Specifications: • Prompt the user to input a wall's height and width. Calculate and output the wall's area. • Extend to also calculate and output the amount of paint in gallons needed to paint the wall. Assume a gallon of paint covers 350 square feet Store this value using a const double variable. • Extend to also calculate and output the number of 1 gallon cans needed to paint the wall. Hint: Use a math function to round up to...