Wave steepness is the ratio of wave height

Assignment Help C/C++ Programming
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;
}

Reference no: EM13165526

Questions Cloud

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?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program to calculate the area of a circle

Write a program to calculate the area of a circle. The program should use two procedures. The first procedure will print out the program heading and ask the user to enter the radius. The second procedure should calculate the area. The area of the cir..

  Write test program to call function several times for gcd

Greatest common divisor of two integers is largest integer which will evenly divide both integers. Implement this function in assembly language and write test program which calls function several times, passing it different values.

  Least number of comparisons needed

What is the least number of comparisons needed to sort an array of 6 numbers, in the worst case, using any sorting algorithm that sorts with binary comparisons? Explain

  File system with login authentication

Implement a simple file system with login authentication and access control - Construct a hash/salt/shadow based user/password creation system.

  During the execution of the above code, how many instru

(a) During the execution of the above code, how many instructions are executed? (b) Assuming a standard unicycle machine (CPI = 1) running at 100 KHz, how long will the above code take to complete?

  Implement the vector class using inheritance

Is it better to implement the Vector class using inheritance (is-a relationship) or composition (has-a relationship). In other word, which one of the following gives a better implementation?

  Binary tree, print right view of it

Given a Binary Tree, print Right view of it. Right view of a Binary Tree is set of nodes visible when tree is visited from Right side.

  Write a program code to compute and build a table of reynold

Write a program code to compute and build a table of Reynolds numbers at flow velocities varying from 100 to 1000 ft/sec (at increments of 100)

  Implement method to advance any given date by one day

Write C++ implementation of this method. Create and specify any other methods that you require. Include comments which will be helpful to someone who will maintain implementation in the future.

  A company that market is publishing both book and audio cass

A company that market is publishing both book and audiocassette versions

  Afunction that raises an integer to a positive integer

Write a function that raises an integer to a positive integer power. Call the function x_to_the_n, taking two integer arguments x and n.

  Build a table of reynolds numbers at flow velocities

Write a program code to compute and build a table of Reynolds numbers at flow velocities varying from 100 to 1000 ft/sec (at increments of 100)

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd