Reference no: EM13165526
Wave steepness is the ratio of wave height (WH) to wave length(WL) and is an indicator of wave stability. When wave steepness exceeds a 1/7 ratio; the wave becomes unstable and begins to break. Assume a data file exits with the following header:
##YY MM DD HH MM WH(m) WL(m)
Each subsequent line in the data file contains time and wave height measurements, in the following format:
year(int) month (int) day (int) hour (int) minute (int) wave height (double) wave length (double)
Write a program to calculate the average steepness given an input file in the above format. The program should also determine and print what percentage of the time the steepness exceeded the average. The input file can be of any length.
Here is what i have so far from a similar question but this is finding the height and not the steepness. filename is "filename.c_str".. i also chose 20 lines in the file
#include
#include
#include
#include
#include
using namespace std;
double average(double[], int);
int main()
{
const int SAMPLE_SIZE = 20;
double waveHeights [SAMPLE_SIZE], WVHT, newVal;
int year, month, day, hour, minute;
string filename, header;
ifstream fin;
cout << "Enter name of input file: ";
cin >> filename;
fin.open(filename.c_str());
if(fin.fail())
{
cerr << "Could not open the file " << filename
<< "Goodbye." << endl;
exit (1);
}
getline(fin,header);
int i = 0;
fin >> year >> month >> day >> hour >> minute >> waveHeights [i];
cout << header << endl;
cout << "Starting time: " < int pos;
for(i=1; i {
fin >> year >> month >> day >> hour >> minute >> newVal;
pos = 0;
while(pos < i && newVal < waveHeights[pos])
{
++pos;
}
if(pos == i)
{
waveHeights[i] = newVal;
}
else
{
for (int k=i; k>pos; --k)
{
waveHeights[k] = waveHeights [k-1];
}
waveHeights[pos] = newVal;
}
}
int top3rd = SAMPLE_SIZE/3;
WVHT = average (waveHeights, top3rd);
cout << "ending time: " << endl << year
<< setw(3) << month << setw(3) << day
<< setw(3) << hour << setw(3) << minute << endl;
cout << "WVHT is " << WVHT << endl;
fin. close();
return 0;
}
double average(double array[], int size)
{
double sum = 0.0;
for(int i=0; i {
sum += array[i];
}
sum = sum/size;
return sum;
}
State what mass of the corresponding sodium salt
: Which of the acids in question #3 would be the best choice to create a buffer with pH = 7.35? If you had 250.0 mL of a 0.20 M solution of the acid, what mass of the corresponding sodium salt of the conjugate base would be required to make the buff..
|
What has happened to the atmospheric pressure
: Now you find yourself on an airplane headed for Israel to visit the Dead Sea, which is below sea level. You have always wanted to visit there and now is your chance. What has happened to the atmospheric pressure?
|
Prepare a trial balance of the general ledger
: Prepare a trial balance of the general ledger and prove the accuracy of the subsidiary ledger by preparing a schedule of accounts receivable.
|
What is the reactant in excess
: Benzene, C6H6, is reacted with bromine, Br2, to produce bromobenzene, C6H5Br, and hydrogen bromide, HBr, as shown below. When 40.0 g of benzene are reacted with 95.0 g of bromine, 65.0 g of bromobenzene is produced.
|
Wave steepness is the ratio of wave height
: Wave steepness is the ratio of wave height (WH) to wave length(WL) and is an indicator of wave stability. When wave steepness exceeds a 1/7 ratio; the wave becomes unstable and begins to break. Assume a data file exits with the following header
|
What is the longest wavelength of light
: The third ionization energy of {rm Fe} is E_{rm i3} = +2952 kJ/mol What is the longest wavelength of light that could ionize Fe^(2+) to Fe^(3+)?
|
What is the ratio of oxygen atoms to hydrogen atoms
: What is the ratio of oxygen atoms to hydrogen atoms in the mineral cacoxenite, Fe4(PO4)3(OH)3 • 12H2O?
|
Calculate the depreciation under the straight line method
: Calculate the depreciation under the straight line method and calculate the depreciation under the double declining method.
|
What is the minimum mass od sodium bicarbonate
: if 100 ml of 3m hcl is spilled on a lab bench, what is the minimum mass od sodium bicarbonate that must be used to neutralized the acid?
|