The document contains C++ code that calculates the amount and cost of paint needed to paint a wall. It takes user input for the wall height and width, calculates the area, then uses functions to determine the coverage per liter, price per liter, amount of paint needed based on area and coverage, and total cost based on amount and price. The program outputs the wall area, amount of paint needed, and total cost of the paint job.
1 of 2
More Related Content
Function paint
1. #include <iostream>
using namespace std;
float priceperlitre();
void coverageperlitre(float&);
float amtofpaint (float, float);
float cost(float, float);
int main()
{
float height, width, areaofwall, areaperlitre, price;
int litre;
float ppl, harga, aop;
cout<<"Height: ";
cin>>height;
cout<<"Width: ";
cin>>width;
areaofwall=height*width;
cout<<"The area of wall : "<<areaofwall<<endl;
coverageperlitre(areaperlitre);
ppl=priceperlitre();
aop=amtofpaint(areaofwall, areaperlitre);
cout<<"The amount paint need: "
<<amtofpaint(areaofwall,areaperlitre)
<<" liter"<<endl;
harga=cost(aop, ppl);
cout<<"The cost is : RM "<<harga<<endl;
system("pause");
return 0;
}
float priceperlitre()
{
float price;
cout<<"Price paint per litre:RM ";
cin>>price;
return price;
}
void coverageperlitre(float& areaperlitre)
{
cout<<"The area that can be painted by a litre : ";
cin>>areaperlitre;