155k views
0 votes
Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompts the user for the length, width, and height of a rectangular room. Pass these three values to a method that does the following: Calculates the wall area for a room Passes the calculated wall area to another method that calculates and returns the number of gallons of paint needed Displays the number of gallons needed Computes the price based on a paint price of $32 per gallon, assuming that the painter can buy any fraction of a gallon of paint at the same price as a whole gallon Returns the price to the main() method The main() method displays the final price. For example:

User TechnoCore
by
4.7k points

1 Answer

2 votes

Answer:

C++

#include <iostream>

#include <cmath>

using namespace std;

///////////////////////////////////////////////////////////////////////

int noOfGallons(int wallArea) {

int gallon = 350;

int gallon_price = 32.0;

float total_price = 0.0;

///////////////////////////////////////////

float noOfGallons = (float)wallArea/(float)gallon;

printf("No of gallons needed %.2f", noOfGallons);

cout<<endl;

//////////////////////////////////////////

total_price = noOfGallons*gallon_price;

return round(total_price);

}

int wallArea(int length, int width, int height) {

int wall_area = length*width;

int total_price = noOfGallons(wall_area);

}

///////////////////////////////////////////////////////////////////////

int main() {

int length, width, height;

///////////////////////////////////////////

cout<<"Enter length: ";

cin>>length;

cout<<"Enter width: ";

cin>>width;

cout<<"Enter height: ";

cin>>height;

cout<<endl;

///////////////////////////////////////////

int total_price = wallArea(length, width, height);

cout<<"Total price: $"<<total_price;

///////////////////////////////////////////

return 0;

}

User Vikram Jakhar
by
5.2k points