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
|
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
double l,w,h,temp,c,volume,surfaceArea; int a,n,m,i,j,k; //declaring global variables
void axialModes(double l,double w, double h,double &c,int &m, vector<double> &mode)
{
for (int i=0; i<n; i++)
{
mode.push_back(c/2*i/l);
cout<<"length mode= "<<i<<" 0 0 "<< mode[i] <<" Hz"<<endl;
if (mode[i]>m)
break;
}
}
int main ()
{
n=5; //determines the maximum number of modes calculated in each of the loops; stops infinite loops
m=300; //determines the frequency at which the modes stop being calculated
c=3; ////// DUMMY VALUE , FIX /////////////
cout<<"What is the width of the room?"<<endl;cin>>w;cout<<endl;
cout<<"What is the length of the room?"<<endl;cin>>l;cout<<endl;
cout<<"What is the height of the room?"<<endl;cin>>h;cout<<endl;
cout<<"What is the temperature of the room in degrees Celsius?"<<endl;cin>>temp;cout<<endl;
cout<<"width= "<<w<<" length= "<<l<<" height="<<h<<endl;
cout<<"temperature= "<<temp;
//declare arrays used in modes:
vector<double> mode;
axialModes(l,w,h,c,m,mode);
cout<<"axial length mode 1= "<<mode[0]<<endl; //this give me a different result from where it was calculated in the function above
return 0;
}
|