# C/C++ Hub

Help me also with this question: a farmer wishes to know the cost and the amount of fertilizer required for his rectangular field of crops. The amount of fertilizer is determined by first calculating the area of a field and multiplying that by the rate of fertilizer application per square metre. Given that the rate of application is 0.05kg per square  meter and the cost per kg of fertilizer is \$10.50 per kg. Write a program that accept the length and width of a given field from the farmer. The program then calculates and prints the area of the field , the amount of fertilizer required and the total cost of fertilizer in dollars

Here is your C++ program

``````#include<iostream>
#include<math.h>

using namespace std;

int main() {

float l,w,area,fertilizer_required,cost;

cout<<"Enter the length of field in meters:";
cin>>l;

cout<<"Enter the width of field in meters:";
cin>>w;

cout<<"---------Result---------"<<endl;
area = l * w;
cout<<"Area of field in sq. meter: "<<area<<endl;

fertilizer_required = area * 0.05;
cout<<"Fertilizer Required in KG: "<<fertilizer_required<<endl;

cost = fertilizer_required * 10.50;
cout<<"Cost in \$: "<<cost<<endl;

return 0;
}

/***
OUTPUT
Enter the length of field in meters:10
Enter the width of field in meters:20
---------Result---------
Area of field in sq. meter: 200
Fertilizer Required in KG: 10
Cost in \$: 105
***/
``````