際際滷

際際滷Share a Scribd company logo
#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;
}


float amtofpaint (float areaofwall, float areaperlitre)
{
   float litre;

    litre= areaofwall/areaperlitre;
    return litre;
}


float cost(float litre, float price)
{
    float costofpaint;

     costofpaint= litre*price;

     return costofpaint;
}

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;
  • 2. } float amtofpaint (float areaofwall, float areaperlitre) { float litre; litre= areaofwall/areaperlitre; return litre; } float cost(float litre, float price) { float costofpaint; costofpaint= litre*price; return costofpaint; }