Question: discribe this code to be #include #include using namespace std; void sortRainfall ( double a [ ] , string b [ ] , int c
discribe this code to be
#include
#include
using namespace std;
void sortRainfalldouble a string b int c;
void getRainfall;
string monthsJanuary "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December";
double rainfall rainfalltotal ;
int main
cout "Please enter the inches of rainfall for the following months:
;
getRainfall;
cout
The total rainfall for the year was rainfalltotal inches.
;
cout "The average monthly rainfall is rainfalltotal inches.
;
sortRainfallrainfallmonths,;
cout "The highest rainfall occurred in months at rainfall inches.
;
cout "The lowest rainfall occurred in months at rainfall inches.
;
cout "The rainfall from highest to lowest is:
;
for int i ; i ; i
cout monthsi: rainfalli inches
;
void getRainfall
fill in rainfall array in this method. Display below if the user tries to enter negative numbers.
forint i;i;i
cout monthsi: ;
cinrainfalli;
ifrainfalli
cout "You cannot enter negative numbers.
;
i;
void sortRainfalldouble rainfall string months int length
int i j;
double temp;
string s;
outer loop to travel through the all elements
for i ; i length ; i
inner loop to compare the outer loop elements
for j ; j length i ; j
if element at j than j than swap both
if rainfallj rainfallj
swap logic
temp rainfallj;
rainfallj rainfallj;
rainfallj temp;
s monthsj;
monthsj monthsj;
monthsj s;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
