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;}
|