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
What do you mean by decentralization??​
Marina CMI [18]

Explanation:

Decentralization—the transfer of authority and responsibility for public functions from the central government to subordinate or quasi-independent government organizations and/or the private sector—is a complex multifaceted concept.

5 0
2 years ago
Read 2 more answers
A DOHC V-6 has how many camshafts?
viktelen [127]

Answer:

two camshafts

Explanation:

4 0
3 years ago
Intravenous infusions are usually driven by gravity by hanging the bottle at a sufficient height to counteract the blood pressur
Bingel [31]

Answer:

(a) BP = 11.99 KPa

(b) h = 2 m

Explanation:

(a)

Since, the fluid pressure and blood pressure balance each other. Therefore:

BP = ρgh

where,

BP = Blood Pressure

ρ = density of fluid = 1020 kg/m³

g = acceleration due to gravity = 9.8 m/s²

h = height of fluid = 1.2 m

Therefore,

BP = (1020 kg/m³)(9.8 m/s²)(1.2 m)

<u>BP = 11995.2 Pa = 11.99 KPa</u>

(b)

Again using the equation:

P = ρgh

with data:

P = Gauge Pressure = 20 KPa = 20000 Pa

ρ = density of fluid = 1020 kg/m³

g = acceleration due to gravity = 9.8 m/s²

h = height of fluid = ?

Therefore,

20000 Pa = (1020 kg/m³)(9.8 m/s²)h

<u>h = 2 m</u>

7 0
3 years ago
you are planning to buy a new couch for your family room you measure the available space and conclude that the couch should be b
nirvana33 [79]
5-6 feet is 60-72 inches and 8 feet is 96 inches
7 0
3 years ago
Discuss three objectives of Tariff and elaborate on three characteristics of it
Margaret [11]

Answer:

Three objectives of a tariff are

1) To control trade between countries

2) To protect domestic industries

3) To provide a source of income

Three characteristics of a tariff are;

1) Adequate return

2) Attractive

3) Fairness

Explanation:

A tariff is an import or export tax placed on goods traded between countries, it serves to control the foreign trade between the two countries and to protect or develop local industry

A Tariff is an important source of income to countries

Three characteristics of a tariff are;

1) Adequate return

Proper return from the consumer should be factored in a tariff to account for the alternatives or normal expense pattern

2) Attractive

The tariff should be attractive to encourage consumption of electricity or complimentary goods

3) Fairness

Based on the consumption of related resources brought about by large scale utilization, large consumer tariff should be lower than those that consume less complementary resources.

5 0
3 years ago
Other questions:
  • You live on a street that runs East to West. You just had 2 inche of snow and you live on the North side of the street. You retu
    14·1 answer
  • A 350 m^3 retention pond that holds rainwater from a shopping mall is empty at the beginning of a rainstorm. The flow rate out o
    7·1 answer
  • Given the circuit at the right in which the following values are used: R1 = 20 kΩ, R2 = 12 kΩ, C = 10 µ F, and ε = 25 V. You clo
    11·1 answer
  • Write a function separatethem that will receive one input argument which is a structure containing fields named length and width
    8·1 answer
  • A mechanical system comprises three subsystems in series with reliabilities of 98, 96, and 94 percent. What is the overall relia
    10·1 answer
  • What is the output of the following program fragment. Choose appropriate data-types of variables to match output.
    10·1 answer
  • Respond with TRUE if the symbol of the valve shown below is
    10·1 answer
  • Consider the following example: The 28-day compressive strength should be 4,000 psi. The slump should be between 3 and 4 in. and
    13·1 answer
  • What type of plans have to do with earth, soil, excavation, and location<br> of a house on a lot?
    12·1 answer
  • An earth fill, when compacted will occupy a net volume of 187,000 cy. The borrow material that will be used to construct this fi
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!