Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

109 02 1992 170 10 Nicaragua 12 02 1992 1000 26 Flores_Island 07 12 1993 239 31

ID: 3569077 • Letter: 1

Question

109 02 1992 170 10 Nicaragua 12 02 1992 1000 26 Flores_Island 07 12 1993 239 31 Okushiri, Japan 06 02 1994 238 14 East_Java 11 14 1994 49 7 Mindoro_Island 10 9 1995 1 11 Jalisco, Mexico 01 01 1996 9 3.4 Sulawesi_Island 02 17 1996 161 7.7 Irian_Javy 02 21 1996 12 5 Peru 07 17 1998 2200 15 Papua,New_Guinea the attached file that contains data for noteworthy tsunamis. Each record has the following fields: month, day, year, fatalities, wave height in meters, location. Write a program that reads the data and prints out a report containing the following: The maximum wave height in feet The average wave height in feet All the locations of the tsunamis that exceeded the average wave height. this the data attached below:

Explanation / Answer

JUST PROVIDE THE "input.txt" FILE CONTAINING ALL THE DATA

#include<iostream>
#include<fstream>
using namespace std;

struct data
{
int month;
int day;
int year;
int fatalities;
float waveHeight;
char location[50];
};

void getData(struct data *tsunamiData, int &i)
{
ifstream file;
file.open("input.txt");
  
  
while(!file.eof())
{
file>>tsunamiData[i].month;
file>>tsunamiData[i].day;
file>>tsunamiData[i].year;
file>>tsunamiData[i].fatalities;
file>>tsunamiData[i].waveHeight;
file>>tsunamiData[i].location;

i++;

   }
  
}
int main()
{
data *tsunamiData = new data[50];
int n=0;
  
getData(tsunamiData, n);
float maxWaveHeight = 0;
float totalWaveHeight = 0;
float avgWaveHeight = 0;
for(int i=0; i<n; i++)
{
   totalWaveHeight+=tsunamiData[i].waveHeight;

   if(maxWaveHeight < tsunamiData[i].waveHeight)
           maxWaveHeight = tsunamiData[i].waveHeight;
}

avgWaveHeight = (float)totalWaveHeight/n;

cout<<"Maximum wave Height is : "<<maxWaveHeight<<" ";
cout<<"Average wave height is: "<<avgWaveHeight<<" ";
cout<<"All location where tsunami exceeded average wave height are: ";

for(int i=0; i<n; i++)
{
   if(tsunamiData[i].waveHeight > avgWaveHeight)
           cout<<tsunamiData[i].location<<" ";
}


  
  
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote