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
yuradex [85]
3 years ago
15

Modify the Rainfall Statistics program you wrote for Programming Challenge 2 of Chapter 7 . The program should display a list of

months, sorted in order of rainfall, from highest to lowest.
Engineering
1 answer:
rjkz [21]3 years ago
8 0

Answer:

#include<iostream>

#include <iomanip>

using namespace std;

const int NUM_MONTHS = 12;

double getTotal(double [], int);

double getAverage(double [], int);

double getLargest(double [], int, int &);

double getSmallest(double [], int, int &);

double getTotal(int rainFall,double NUM_MONTHS[])

{

double total = 0;

for (int count = 0; count < NUM_MONTH; count++)

total += NUM_MONTH[count];

return total;

}

double getAverage(int rainFall,double NUM_MONTH[])

{getTotal(rainFall,NUM_MONTH)

average= total/NUM_MONTHS;

return average;

}

double getHighest(int rainFall, double NUM_MONTHS[]) //I left out the subScript peice as I was not sure how to procede with that;

{

double largest;

largest = NUM_MONTHS[0];

for ( int month = 1; month <= NUM_MONTHS; month++ ){

                     if ( values[month] > largest ){

                 largest = values[month];

return largest;

          }

double getSmallest(int rainFall, double NUM_MONTHS[])

{

double smallest;

smallest = NUM_MONTHS[0];

for ( int month = 1; month <= NUM_MONTHS; month){

                     if ( values[month] < smallest ){

                 smallest = values[month];

return smallest;

          }

 

int main()

{

double rainFall[NUM_MONTHS];

 for (int month = 0; month < NUM_MONTHS; month++)

  {

     cout << "Enter the rainfall (in inches) for month #";

     cout << (month + 1) << ": ";

     cin >> rainFall[month];

 

     while (rainFall[month] < 0)

     {

      cout << "Rainfall must be 0 or more.\n"

             << "Please re-enter: ";

      cin >> rainFall[month];

     }

  }

  cout << fixed << showpoint << setprecision(2) << endl;

  cout << "The total rainfall for the year is ";

  cout << getTotal(rainFall, NUM_MONTHS)

      << " inches." << endl;

   cout << "The average rainfall for the year is ";

  cout << getAverage(rainFall, NUM_MONTHS)

      << " inches." << endl;

   int subScript;

cout << "The largest amount of rainfall was ";

  cout << getLargest(rainFall, NUM_MONTHS, subScript)

      << " inches in month ";

  cout << (subScript + 1) << "." << endl;

  cout << "The smallest amount of rainfall was ";

  cout << getSmallest(rainFall, NUM_MONTHS, subScript)

      << " inches in month ";

  cout << (subScript + 1) << "." << endl << endl;

  return 0;

}

You might be interested in
A negative pressure respirator brings fresh air to you through a hose<br>A) True<br>B)False​
madreJ [45]

Answer:FALSE

Explanation: A negative pressure respirator is a respiratory system which is known to have a low air pressure inside the mask when compared to the air pressure on the outside during Inhalation.

Most of the personal protective equipment (PPE) which are in use in various industries are examples of Negative pressure respirator device,any leak or damage done to the device will allow the inflows of harmful and toxic Air into the person's respiratory system. AIR SUPPLY SYSTEMS ARE KNOWN TO SUPPLY FRESH UNCONTAMINATED AIR THROUGH AIR STORED INSIDE COMPRESSED CYLINDERS OR OTHER SOURCES AVAILABLE.

8 0
3 years ago
Read 2 more answers
Diffusion of Ammonia in an Aqueous Solution Ammonia (A)-water (B) solution ta 278 K and 4 mm thick is in contact with an organic
Tom [10]

Answer:

Explanation:

The pictures below shows the whole explanation for the problem

4 0
3 years ago
Discuss typical advantages and disadvantages of an irrigation system?
trapecia [35]
Advantages include low costs and minimal labor.Water stays in the root zone, and foliage stays dry. Drawbacks to surface irrigation include potential overwatering and wasteful runoff.
4 0
3 years ago
Common car loan duration
chubhunter [2.5K]

Answer:

In 2019, the average term length was 69 months for new cars and 65 months for used vehicles. Most car loans are available in 12 month increments, lasting between two and eight years. The most common loan terms are 24, 36, 48, 60, 72, and 84 months, according to Autotrader

Explanation:

4 0
2 years ago
Which of the following has led to a safer and more prosperous global community within the last century? the Bronze Age composite
sattari [20]

Answer:

The bronze age

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is the maximum number of 12-2 with ground nonmetallic-sheathed cables permitted in an 18-cubic-inch device box if two singl
    11·2 answers
  • Technician A says that thrust angle refers to the direction the front wheels are pointing. Technician B says that scrub radius r
    11·1 answer
  • Marcelo es muy bueno resolviendo adivinanzas y acertijos. Por eso, estaba totalmente disgustado cuando se dio cuenta de que no e
    12·1 answer
  • A 10-mm steel drill rod was heat-treated and ground. The measured hardness was found to be 290 Brinell. Estimate the endurance s
    14·1 answer
  • The concrete canoe team does some analysis on their design and calculates that they need a compressive strength of 860 psi. They
    15·1 answer
  • Hiiiiiiiii<br> jhajwjne f f g. g g tnnjzjnsnsnend f najjwne d f nskiaksjsjsjksm
    5·1 answer
  • What else will change, if you change the point of view
    10·1 answer
  • ILL GIVE BRAINLIEST!!!
    11·1 answer
  • Joey has a car that uses the hand crank to open the windows. Joey is wondering where the energy comes from to open the windows.T
    11·1 answer
  • 3) Explain how dc machines Can work as motor and generator​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!