Answer to Question #178024 in C++ for Abdullah Ramzan

Question #178024

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.


1
Expert's answer
2021-04-03T12:12:23-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS