Hey all, I have some work that I'm stuck on.
I've been tasked with creating a basic system that classifies hurricane speed into one of 5 categories. I can pre set the information onto a txt file then read it from the program. However, The information that is preset must be categorized into categories.
For instance the in the code I read a txt file that I have already set. Down below. In the txt file Identification (Picture attached) I've written down 3 identification numbers that have 3 different peak winds (the identification number does not matter but the peak wind does). I'd like the code to go through the file and organize the information into the different categories which are.
If peak wind > 50 and < 70 = category 1
else if peak wind > 70 and < 100 = category 2
else if peak wind > 100 and < 130 = category 3
In this case the identification.txt contains one of which I'd like the file to be read and a category to be displayed next to each identification number
Imgur: The magic of the Internet
Identification || Peak Wind (mph) || Category
121 || 47 || 0
41 || 93 || 1
60 ||120 || 2
Code:void HurricaneIdentification() { printf("The following values are the registered hurricanes, along with a unique identification number for each.\n"); FILE *fileIdentification; fileIdentification = fopen("Identification.txt", "r"); char singleLine[150]; while (!feof(fileIdentification)) { fgets(singleLine, 150, fileIdentification); puts(singleLine); } fclose(fileIdentification); main(); return; }
Any help is greatly appreciated.