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.
#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;
}
Comments
Leave a comment