Hey guys, this is my first post I hope to learn some new things. This is my 3rd homework assignment in my first programming class. I attend the University of Iowa. This homework is a monster and i did a lot of it but i'm lost on when to use my blocking while loops and how to continue on with my problem once the user grading my program enters his values within the parameters given below. Here's my code and the equation I have. Any help would be appreciated greatly. Thanks !
The program should ask the user for the following parameters:
{L – thickness of the circuit board between 0.005m and 0.008m}
{Tside – temperature of the sides between 200C and 250C}
{type – type of material: material 1, material 2, material 3}
{t – the time after which you want to check the temperature, in seconds} {Tinitial – the initial temperature inside the board between 500C and 1000C}
{x – the spatial point at which you want to check the temperature, in meters}
The equation i have to solve is in my code but its only part of it. It's:
[Solve T for x=L/2 & x=0]
T(x,t) = T[side] + 2(T[initial - T[side] * Sum for n=1 to n=100 (of the equation below)
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
|
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
int main () {
double Tside=25, Tinitial=50, Lthickness=0.005, typeM=0.00001, SpatialPoint=Lthickness/2, time=5;
double Temp1, Temp2, CoolingOff;
int number, n;
cout << "Enter a number between 20 and 25";
cin >> number;
while (number >= 20 || number <= 25)
{
cout << "Error ! Enter number again !" << flush;
cin >> number;
}
cout << "Enter a number between 50 and 100";
cin >> number;
while (number >= 50 || number <= 100)
{
cout << "Error ! Enter number again !" << flush;
cin >> number;
}
cout << "Enter a number between 0.005 and 0.008";
cin >> number;
while (number >= 0.005 || number <= 0.008)
{
cout << "Error ! Enter number again !" << flush;
cin >> number;
}
cout << "Enter a number between 1 and 50";
cin >> number;
while (number >= 1 || number <= 50)
{
cout << "Error ! Enter number again !" << flush;
cin >> number;
}
cout << "Please enter the temperature of the sides." << endl;
cin >> Tside;
cout << "Please enter the initial temperature inside the board." << endl;
cin >> Tinitial;
cout << "Please enter the thickness of the circuit board." << endl;
cin >> Lthickness;
cout << "Please enter the type of material." << endl;
cin >> typeM;
cout << "Please enter the spatial point at which you want to check the temperature." << endl;
cin >> SpatialPoint;
cout << "Please enter the the after which you want to check the temperature (in seconds)" << endl;
cin >> time;
int Temp1Sum, Sum = 0;
for( n=1; n <= 100; n++)
{
Temp1Sum = exp((-(n*M_PI)*(n*M_PI))*((typeM*(time))/(Lthickness*Lthickness)))*((1.0-cos(n*M_PI))/(n*M_PI))*sin((n*M_PI*(Lthickness/2))/(Lthickness));
{ Sum += Temp1Sum;
{ cout << Sum;
}}} return 0;}
|