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

  You will write a program that reads a text file

You will write a program that reads a text file, counts the number of words in the file, and the number of occurrences of each character. It will print to a file the number of words, and the number of occurrences of each character, as well as the ..

  Perform operations on arrays

Perform operations on arrays execute tests and repetitions

  Determine the meaof the numbers in the array

Determine the mean(average) of the numbers in the array, and output the reslt. Use a subprogram to input the numbers, a function to find the mean.

  How a base version of this assignment works

For this assignment you are to create an interactive moving sign in the context of a cityscape street scene. Click the link below to see how a base version of this assignment works. Type a message in the long blank slot at the top left, and then clic..

  Write program to input series of hourly temperatures

Create and write a c++ program which inputs series of 24 hourly temperatures from file, and outputs bar chart (using stars) of temperatures for the day.

  Write a program that asks the user to enter the names of 3

Write a program that asks the user to enter the names of three salesmen. The program should thenaccept the sales produced for salesman for each quarter of the year. Display the name, and the totalsales amount, of each salesman.

  Create a text adventure game that uses pointers

Create a text adventure game that uses pointers. You have a rich, eccentric Uncle Billy who is soon to be deceased.

  Two types of constructors

Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constru..

  You will create a linked list module

You will create a linked list module that exactly meets the specifications given in the supplied header (.h) file. The playlist program must accept a filename on the command line (argv).

  Write a complete c++ program

The main program will read in a parameter value n (read this in main). Then it will call a function read2arrays (details below) to read lists of grades into two arrays, which the main program will call test1 and test2 (or some other names of your ..

  Write a very basic doubly-linked list

CptS 122 Lab #2: Linked Lists ,  Along with vectors, linked lists are one of the fundamental data structures in computer science. Unlike vectors, which store information in a contiguous block of computer memory, linked lists have the potential to sto..

  Iimplement a client-server of the game

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

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