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

The following lists are the tsunami information stored in waves.txt file as mont

ID: 3656110 • Letter: T

Question

The following lists are the tsunami information stored in waves.txt file as month, date, year, fatalities, maximum wave height, and fatalities format. 09 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 03 11 2011 15690 39.8 Tohoku,Japan Write a C program to read data using structure and print fatalities from tsunami wave more than 10m. Use an output format similar to the following: Information for the Large Tsunami from the 1990s Date Location Maximum Wave (m) Fatalities

Explanation / Answer

#include #include struct TsunamiInfo{ int month,date,year; int fatalities; double maxWaveHeight; char location[500];//static array of max 500 char }; int main(){ FILE *fo; FILE *fp; struct TsunamiInfo TList[500];// static array of max 500 entries of type TusnamiInfo int TListcount=0; int i; fo=fopen("waves.txt","r"); if(fo==NULL){//if not open printf("Input File failed to open..."); getch(); //get a key return 0; //and exit } while(!feof(fo)){ fscanf(fo,"%d",&i);//try reading data if(!feof(fo)){ //if data was not eof flag TList[TListcount].month=i; fscanf(fo,"%d %d",&TList[TListcount].date,&TList[TListcount].year); fscanf(fo,"%d %lf %s",&TList[TListcount].fatalities,&TList[TListcount].maxWaveHeight,&TList[TListcount].location); TListcount++; } } fclose(fo); printf(" Information for the Large Tsunami from the 1990s Date Location Max. Wave (m) Fatalities"); for(i=0;i10.0){ printf(" %d/%d/%d",TList[i].month,TList[i].date,TList[i].year); printf(" %-18s %-1.3lf %-d",TList[i].location,TList[i].maxWaveHeight,TList[i].fatalities); } } cout