My "perimeter and surface area" isn't getting correct values in for loop

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;




int main()
{
	
	
	double depth = 5;
	double length = 10;
	double width = 10;
	 double perimeter = ((2*width) + (2*length));
	double sa = ((2*(length*depth)) + (2*(width*depth)) + (length*width));

	cout<<"This program will calculate the perimeter and surface area of a pool"<<endl;
 cout<<"The depth of the pool is constant at 5 feet"<<endl<<endl;

 cout<< "Length  Width  Perimeter  Surface Area\n";
 cout<< "------  -----  ---------  ------------\n";

 for (length = 10; length <=12; length +=1)
	

 for (width = 10; width <= 20; width +=5)
	

	 cout<<fixed<<setprecision(2)<<setw(7)<<length<<setw(6)<<width
		 <<setw(10)<<perimeter<<setw(13)<<sa<<endl;
	 cout<<endl<<"Thank you for using this program"<<endl;



	system("Pause");
	return 0;
}
Last edited on
It is only using the equation for the first "go through", and then using those values for all the rest, i don't know why.
Topic archived. No new replies allowed.