Formatting my output

Okay so I have this is the project that I have to write my code for:

Make a table for the maxheatloss of a cylindricaltanks that has different H and R.

We know heat loss from top : qW = k * A * (TH - TC) / W

We know heat loss from side : qR = [2 * pi * k * L * (TH - TC)] / [ ln (r0 / ri)]

..... (I left some of what we're supposed to do because I already wrote the code for that)....

At the end, I need a program that outputs a table that puts my heights do the left as the columns and along the top puts my radii as the rows. And within the table should be the maxheatloss for that specific cylinder. These numbers should be followed by either a 'T','S',or and 'E'. A 'T' if qw>qr, 'S' if qw<qr ,or 'E' if they're equal. The table should have the decimals in the numbers lined up and have proper labels

the final result should look something like this (except there should be number filled into the rows):

tank radii
tank height (ft) 3.00 3.50 4.00 4.50 5.00 5.50 6.00
02.00 2.17T
03.00
04.00
05.00
06.00
07.00
08.00 3.87S
09.00
10.00

The outputting of the table is the part that I'm stuck on. I know that I need to create some loops where I plug in my equations and evaluate them over a certain range but I'm not exactly sure how to do this. I also don't know what I should be using to create the actual table. I don't think I want to do "\t" because I want to align everything by the decimal so that it lines up exactly. This is what I have so far and if anyone has any suggestions that would be great:

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#include <iostream>        
#include <cmath>  
#include <iomanip>                
#define PI 3.141592653589793     
#include <sstream>      

using std::cout;
using std::setprecision;   //I put this in but I'm not really sure if I need it
using std::fixed;

using namespace std;

int main (void) {
		           
double W, K, TH, TC, L, lowestLength, numberOfLengths, incrementOfLengths, Ri, lowestRadius, numberOfRadius, incrementOfRadius, Ro, greatestLength, greatestRadius, A, qW, qR, col, row, heightOfColumn, lengthOfRow;

cout<<fixed<<setprecision(2);     
         
          //The following asks the user to enter the thickness of the tank

do 
          {      
                 cout<<"What is the thickness of the tank? (in inches) :";
                 cin>>W;
                 cout<< "\n";

                 if (W<0)
                 cerr<< "The thinkness can't be less than zero. ";                   
          }                                                           
          while (W<0); 

  //The following asks the user to enter the thermal conductivity of the tank

do
          {
                cout<<"What is the thermal conductivity of the tank walls? (in Btu/(hr*ft*deg F)) :";
                cin>>K;
                cout<< "\n";

                if (K<0)
                cerr<< "For this program, the thermal conductivity should not be less than zero. ";  
          }                                                                                          
          while (K<0);

 //The following asks the user to enter the temperature inside of the tank

do
          {
                cout<<"What is the temperature inside of the tank? (in degress F) :";
                cin>>TH;
                cout<< "\n";

                if (TH<-500)                                                                                             
                cerr<< "For this program, the temperature inside of the tank has to be greater than -500 degrees F. ";   
          }
          while (TH<-500);

//The following asks the user to enter the temperature outside of the tank

do
          {
                cout<< "What is the temperature outside of the tank? (in degress F) :";
                cin>>TC;
                cout<< "\n";

                if (TC<-500)                                                                                             
                cerr<< "For this program, the temperature outside of the tank has to be greater than -500 degrees F. ";  
                else if (TC>TH)
                cerr<< "The temperature inside of the tank has to be greater than the temperature outside of the tank. ";
          }                                                                                                              
          while (TC>TH && TC<-500);


        //The following asks the user to enter what the minimum height will be

do 
          { 
                 cout<< "What is the minimum height? (in feet) :";
                 cin>>lowestLength;
                 cout<< "\n";

                 if (lowestLength<=0)                                    
                 cerr<< "The minimum height can't be less than zero. ";  
          } 
          while (lowestLength<=0);  

     //The following asks the user to enter how many heights there will be

do
          { 
                cout<< "How many heights are there? :";
                cin>>numberOfLengths;
                cout<< "\n";

                if (numberOfLengths<=0)                                      
                cerr<< "The number of heights must be greater than zero. ";            }
          while (numberOfLengths<=0);

//The following asks user to enter what to increment length by

do
          { 
                cout<< "What would you like the increment for height to be? :";
                cin>>incrementOfLengths;
                cout<< "\n";

                if (numberOfLengths>1 && incrementOfLengths<=0)                                         
                cerr<< "You must increment by more than zero when you have more than one height. ";     
          }
          while (incrementOfLengths<=0);

//The following asks the user to enter the minimum length for the radius 

do
          { 
                cout<< "What is the minimum value of the radius? (in feet) :";
                cin>>lowestRadius;
                cout<< "\n";

                if (lowestRadius<=0)                                                    
                cerr<< "The minimum value for your radius must be greater than zero. ";
          }
          while (lowestRadius<=0);

          //The following asks the user to enter how many radii there will be

do
          { 
                cout<< "How many radii are there? :";
                cin>>numberOfRadius;
                cout<< "\n";

                if (numberOfRadius<=0)                                     
                cerr<< "The number of radii must be greater than zero. ";  
          }
          while (numberOfRadius<=0);

//The following asks the user to enter the value to increment the radii by

do
          { 
                cout<< "What would you like the increment for radii to be? :";
                cin>>incrementOfRadius;
                cout<< "\n";

                if (numberOfRadius>1 && incrementOfRadius<=0)                                         
                cerr<< "You must increment by more than zero when you have more than radius. ";       
          }
          while (incrementOfRadius<=0);
          
/*The following equations will calculate what the largest length and largest radius will be*/

greatestRadius=lowestRadius+((numberOfRadius-1)*incrementOfRadius);        
greatestLength=lowestLength+((numberOfLengths-1)*incrementOfLengths);

/*HERE IS WHERE I DON'T KNOW WHERE TO GO FROM. I HAVE ALL THE EQUATIONS BUT I HAVE NO IDEA WHAT TO DO WITH THEM AND HOW TO GET THEM INTO A TABLE*/


for (L=lowestLength;L<=greatestLength;L+=incrementOfLengths) 
/*This loop is used to determine the heights*/
{
    cout<<setw(12)<<"Tank Height (FT)";
    cout<<fixed<<left<<setprecision(2)<<L;
	     
for (Ri=lowestRadius;Ri<=greatestRadius;Ri+=incrementOfRadius) //This loop is used to determine the radii
{
    cout<<fixed<<setprecision(2);
    cout<<setw(10)<<"Tank Height (FT)"<<setw(10)<<Ri;
    
    W=W/12;                              
    Ro=Ri+W;                             
    A=PI*Ri*Ri;                         
    qW=(K*A*(TH-TC))/W;                 
    qR=(2*PI*K*L*(TH-TC))/(log(Ro/Ri));  
    
    
    
   if (qW>qR)
   {cout<<fixed<<setprecision(2);
   cout<<fixed<<setw(3)<<qW<<" T ";}
   else if (qW<qR)
   {cout<<fixed<<setprecision(2);
   cout<<fixed<<setw(3)<<qR<<" S ";}
   else if (qW=qR)
   {cout<<fixed<<setprecision(2);
   cout<<fixed<<setw(3)<<qW<<" E ";}
}}


    system("PAUSE");
    return EXIT_SUCCESS;}
  


well actually that table didn't turn out how it should have.
its basically just supposed to be the radii values along the horizon at the top
and the height values to the left vertically with values of heat plugged into the table.
The horizon needs to be labeled radius and vertical labeled height
You're using "cin" but you didn't put using std::cin; anywhere...?
oops. fixed it
in 184 line change = to == else if (qW==qR)
Topic archived. No new replies allowed.