A carpenter wants to make a ladder, but he want to calculate the required wood for it. The distance between each step is 1 foot. Write a C++ program in which, take the length and width of ladder as input from user and calculate the required wood. Price of wood is 500 per foot, now calculate the price of wood as well.
#include <iostream>
using namespace std;
int main(){
int length;
int width;
int requiredWood;
int balanceJuice;
int costWood;
//read the length of ladder in foot
cout<<"Enter the length of ladder in foot: ";
cin>>length;
//read the width of ladder in foot
cout<<"Enter the width of ladder in foot: ";
cin>>width;
//calculate the required wood in foot
requiredWood=(length-1)*width+length*2;
cout<<"Required wood in foot: "<<requiredWood<<"\n";
//calculate the price of wood
costWood=requiredWood*500;
cout<<"Cost of wood: "<<costWood<<"\n\n";
return 0;
}
Comments
Leave a comment