1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Maru [420]
1 year ago
7

In C++ please (read the image below for instructions)

Computers and Technology
1 answer:
FromTheMoon [43]1 year ago
8 0

Using the knowledge in computational language in C code  it is possible to write a code that  print the month name along with their rainfall inches. Then we have to calculate the total rainfall.

<h3>Writting the code:</h3>

<em>#include <bits/stdc++.h></em>

<em>using </em><em>namespace </em><em>std;</em>

<em />

<em>// function to print the rainfall of each month</em>

<em>void rainfallStatistics(string month[], double rainfall[]){</em>

<em>    </em>

<em>    double sum = 0; // variable to store the total sum of rainfall</em>

<em>    string maxMonth = month[0]; // variable to return month with maximum rainfall</em>

<em>    double </em><em>maxRainfall </em><em>= INT_MIN; // variable to store the maximum rainfall</em>

<em>    </em>

<em>    // running the loop till the last month</em>

<em>    for(int i=0; i<12; i++){</em>

<em>        </em>

<em>        // printing the month and rainfall</em>

<em>        cout<< month[i] << "           " << fixed << setprecision(2) << rainfall[i] << " inches" << endl;</em>

<em>        </em>

<em>        // storing the sum</em>

<em>        sum = sum + rainfall[i];</em>

<em>        </em>

<em>        // checking the month with highest rainfall</em>

<em>        if(rainfall[i] > </em><em>maxRainfall</em><em>){</em>

<em>            </em>

<em>            maxRainfall = rainfall[i];</em>

<em>            maxMonth = month[i];</em>

<em>        }</em>

<em>    }</em>

<em>    </em>

<em>    // calculating the average of the rainfall</em>

<em>    double average = sum / double(12);</em>

<em>    </em>

<em>    cout << endl;</em>

<em>    cout << "Total for the year " << sum << " inches" << endl;</em>

<em>    cout << "Average rainfall per month " << average << " inches" << endl;</em>

<em>    cout << "Month with the greatest rainfall was " << maxMonth << " with rainfall of " << </em><em>maxRainfall </em><em><< " inches" << endl;</em>

<em>    </em>

<em>}</em>

<em>// driver program</em>

<em>int main()</em>

<em>{</em>

<em>    // array to store the nonth name</em>

<em>    string month[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};</em>

<em>    </em>

<em>    // array to store the rainfall</em>

<em>    double rainfall1[12] = { 4.50, 4.25, 3.26, 1.35, 0.80, 0.20, 0.10, 0.00, 0.40, 1.20, 2.96, 4.71 };</em>

<em>    double rainfall2[12] = { 3.50, 1.25, 7.26, 8.35, 2.80, 0.00, 1.10, 4.00, 9.40, 2.20, 3.96, 4.71 };</em>

<em>    </em>

<em>    cout << "Hayward Statistics" << endl;</em>

<em>    cout << endl;</em>

<em>    cout<< "Month" << "         " << "Rainfall" << endl;</em>

<em>    </em>

<em>    // calling the function for Hayward</em>

<em>    </em><em>rainfallStatistics</em><em>(month, rainfall1);</em>

<em>    cout << endl;</em>

<em>    cout << endl;</em>

<em>    </em>

<em>    cout << "Houston Statistics" << endl;</em>

<em>    cout << endl;</em>

<em>    cout<< "Month" << "         " << "Rainfall" << endl;</em>

<em>    </em>

<em>    // calling the function for Houston</em>

<em>    rainfallStatistics(month, rainfall2);</em>

<em>    </em>

<em>    return 0;</em>

<em>}</em>

See more about c code at brainly.com/question/19705654

#SPJ1

You might be interested in
A bare metal area surrounded by body filler after sanding indicates:
Lera25 [3.4K]

its a high spot being sanded im in auto body as well.

8 0
3 years ago
20
denis-greek [22]

Answer:

true

Explanation:

because my 8 ball said so

6 0
3 years ago
There is a huge demand for cyber security professionals. True or false
STatiana [176]
True.
Thank You!
Please mark Brainliest
5 0
3 years ago
Read 2 more answers
In what explicit way did Eye of the Storm include reader participation?
Naddika [18.5K]
The group is divided into two groups. They have themselves introduced and have welcomed participants. The objective is to consider action to challenge discriminatory treatment. Have the group understand and recognize discrimination. Ground rules were created to have supportive learning environment.
6 0
2 years ago
Read 2 more answers
To turn off the AutoCorrect features, navigate to the AutoCorrect menu and deselect the box labeled_____.
barxatty [35]
Option A-Show AutoCorrect buttons, then you have the options to hide the autocorrect or to turn it on/off
4 0
3 years ago
Read 2 more answers
Other questions:
  • The Online Shopping system facilitates the customer to view the products, inquire about the product details, and product availab
    8·1 answer
  • In which career field would the computing technology industry associations compTIA A+ certification be useful
    6·1 answer
  • Late at night, some traffic signals change patterns and become _____.
    9·2 answers
  • The incompatibilities in speed between the various devices and the CPU make I/O synchronization difficult, especially if there a
    6·1 answer
  • Which of the following operating systems includes a virtual assistant?<br> Group of answer choices
    8·1 answer
  • which program monitors the computer by looking for known trouble makers as well as suspicious behavior​
    11·1 answer
  • Why do people make Among Us games on Ro-blox, and thousands of people play them, when Among Us is free on all devises?
    10·1 answer
  • A(an)_______is built-in preset calculation. <br>formula <br> function <br>equation <br>AutoSum​
    12·1 answer
  • When light hits an opaque object it will be _______________.
    8·1 answer
  • Your older brother Max tells you about his secret plan to hack into his college’s computer network and change all of his grades.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!