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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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