Answer to Question #313010 in Algorithms for KeKo

Question #313010

Write a small program called window.cpp to calculate the cost of a rectangular window. The total cost of a window is based on two prices; the cost of the glass plus the cost of the metal frame around the glass. The glass is 50 cents per square inch (area) and the metal frame is 75 cents per inch (perimeter). The length and width of the window will be entered by the user. The user will also enter y or n, to indicate whether or not the customer wants delivery. If the customer wants the window delivered, there is an extra charge of $50. The output of the program should be the length and width (as entered by the user) and the total cost of the window, including delivery if requested.


1
Expert's answer
2022-03-18T12:13:48-0400






#include <iostream>
using namespace std;




int main()
{
	float length,width,totalCost;
	char answer;
	cout<<"Enter the length and width of the window: ";
	cin>>length>>width;
	float costGFlass=length*width*0.5;
	float costMetalFrame=2*0.75*(length+width);
	totalCost=costGFlass+costMetalFrame;
	cout<<"Does the customer want delivery? y/n: ";
	cin>>answer;
	if(answer=='y'){
		totalCost+=50;
	}
	cout<<"The total cost of a window is: $"<<totalCost<<"\n\n";




	system("pause");


	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