Question: Please check my coding, idont get the exactly ouput as question ask.#include #include #include using namespace std; struct Rain { char city[20]; char state [20];
Please check my coding, idont get the exactly ouput as question ask.#include
#include
#include
using namespace std;
struct Rain
{
char city[20];
char state [20];
int amountRain [6];
};
int &totRainfall(Rain Rainfall[],ifstream &myfile);
string highestRainfall(Rain Rainfall[]);
int*totalamountRain;
int i,j;
string highest;
int main()
{
Rain Rainfall[12];
ifstream myfile;
myfile.open("RainWater.txt");
ofstream output;
output.open("JsrainWater.txt");
int i = 0;
while(!myfile.eof())
{
getline(myfile,Rainfall[i].city,';');
getline(myfile,Rainfall[i].state,';');
for(int j =0; j
{
myfile>>Rainfall[i].amountRain[j];
myfile.ignore();
}
i++;
}
for (int k = 0; k
{
cout
cout
for(int j = 0; j
{
cout
}
cout
}
if(myfile.fail())
{
cout
exit(1);
}
totalamountRain = &totRainfall(Rainfall,myfile);
highest = highestRainfall(totalamountRain);
output
output
output
myfile.close();
output.close();
system ("pause");
return 0;
}
int &totRainfall(Rain Rainfall[],ifstream &myfile)
{
static int totalamount[2] = {0,0};
while(myfile>>Rainfall[i].city>>Rainfall[i].state)
{
for(int j = 0; j
{
myfile>>Rainfall[i].amountRain[j];
}
if(!strcmpRainfall[i].state,"Selangor")
{
totalamountRain[0] = totalamountRain[0] + Rainfall[i].amountRain[j] ;
}
else if (!strcmpRainfall[i].state,"Johor")
{
totalamountRain[1] = totalamountRain[1] + Rainfall[i].amountRain[j] ;
}
return totalamountRain[0], totalamountRain[1];
}
}
string highestRainfall(Rain Rainfall[])
{
{
if (Rainfall[0]>Rainfall[1])
return "Selangor";
else
return "Johor";
}
}

![#include #includeusing namespace std;struct Rain{ char city[20]; char state [20]; int amountRain](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/10/670fd5b4c0795_996670fd5b4af558.jpg)
C:\\Users\\BalqisKhai\\Documents\\-EDUCATION UITM-\\CSC404 -PROGRAMMING\\File IO\\Assignment 4.cpp - [Executing] - Dev-C+ + 5.11 X File Edit Search View Project Execute Tools AStyle Window Help * h x TDM-GCC 4.9.2 64-bit Release V (globals) Project Classes . Assignment 4.cpp 47 9 { 48 while(myfile . eof ( ) ) 49 8 56 myfile >> Rainfalllil.state: 51 if (Rainfall[i]. JsrainWater - Notepad X 528 53 for (int j = File Edit Format View Help 548 count rain received by all cities in Selangor is 8394152 55 ount rain received by all cities in Johor is 8394152 Rainfal hich received highest amount of rain from January to Jun is 0 56 57 58 Rainfall[ i] 59 60 else if (Rainfa for (int k = Ln 1, Col 1 100% Windows (CRLF) UTF-8 Rainfall[i] . amountRain[k]++; 65 66 67 68 Compiler Resources lli Compile Log Debug C Find Results $3 Close Abort Compilation Errors: 0 Warnings: 0 Output Filename: C: \\Users\\BalqisKhai\\Documents\\-EDUCATION UITM-\\CSC404 -PROGRAMMING\\File IO\\Assignment 4. exe Shorten compiler paths Output Size: 1. 83406639099121 MiB Compilation Time: 1.20s Activate Windows Go to Settings to activate Windows. Search for anything W DEV 1:12 PTG C+ A D ( )MSA 24/06/2020JsrainWater - Notepad X File Edit Format View Help Total of amount rain received by all cities in Selangor is 8394152 Total of amount rain received by all cities in Johor is 8394152 The state which received highest amount of rain from January to Jun is 0 Activate Windows Go to Settings to activate Windows. Ln 1, Col 1 100% Windows (CRLF) UTF-8 Search for anything DEV PD ( ) MSA 1:14 PTG C+ 24/06/2020
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
