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
sertanlavr [38]
2 years ago
15

Write a program that lets the user enter the total rainfall for each of 12 months into a vector of doubles. The program will als

o have a vector of 12 strings to hold the names of the months. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.
Computers and Technology
1 answer:
madam [21]2 years ago
3 0

Answer:

Explanation:

#include<iostream>

#include<iomanip>

#include<vector>

using namespace std;

double getAverage(const vector<double> amounts)

{

   double sum = 0.0;

   for (int i = 0; i < amounts.size(); i++)

       sum += amounts[i];

   return(sum / (double)amounts.size());

}

int getMinimum(const vector<double> amounts)

{

   double min = amounts[0];

   int minIndex = 0;

   for (int i = 0; i < amounts.size(); i++)

   {

       if (amounts[i] < min)

       {

           min = amounts[i];

           minIndex = i;

       }

   }

   return minIndex;

}

int getMaximum(const vector<double> amounts)

{

   double max = amounts[0];

   int maxIndex = 0;

   for (int i = 0; i < amounts.size(); i++)

   {

       if (amounts[i] > max)

       {

           max = amounts[i];

           maxIndex = i;

       }

   }

   return maxIndex;

}

int main()

{

   vector<string> months;

   vector<double> rainfalls;

   months.push_back("January");

   months.push_back("February");

   months.push_back("March");

   months.push_back("April");

   months.push_back("May");

   months.push_back("June");

   months.push_back("July");

   months.push_back("August");

   months.push_back("September");

   months.push_back("October");

   months.push_back("November");

   months.push_back("December");

   cout << "Input 12 rainfall amounts for each month:\n";

   for (int i = 0; i < 12; i++)

   {

       double amt;

       cin >> amt;

       rainfalls.push_back(amt);

   }

   cout << "\nMONTHLY RAINFALL AMOUNTS\n";

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

   for (int i = 0; i < 12; i++)

       cout << left << setw(11) << months[i] << right << setw(5) << rainfalls[i] << endl;

   cout << "\nAVERAGE RAINFALL FOR THE YEAR\n" << "Average: " << getAverage(rainfalls) << endl;

   int minIndex = getMinimum(rainfalls);

   int maxIndex = getMaximum(rainfalls);

   cout << "\nMONTH AND AMOUNT FOR MINIMUM RAINFALL FOR THE YEAR\n";

   cout << months[minIndex] << " " << rainfalls[minIndex] << endl;

   cout << "\nMONTH AND AMOUNT FOR MAXIMUM RAINFALL FOR THE YEAR\n";

   cout << months[maxIndex] << " " << rainfalls[maxIndex] << endl;

   return 0;

}

You might be interested in
What sequence is used to create a brochure document from a template?
GenaCL600 [577]

Answer:

computer is used to create a voucher document

6 0
2 years ago
Read 2 more answers
The it components of an erp system architecture include the hardware, software and the ________
natta225 [31]

The components of an ERP system architecture is made up of the hardware, software and the Data.

<h3>What is an ERP system?</h3>

Enterprise resource planning (ERP) is known to be a kind of  software that firms often use to handle or manage day-to-day business works such as accounting and others.

Note that The components of an ERP system architecture is made up of the hardware, software and the Data.

Learn more about  ERP system from

brainly.com/question/14635097

#SPJ12

6 0
2 years ago
What is the first character for a file or directory names if they should not be displayed by commands such as ls unless specific
riadik2000 [5.3K]

Answer: The .(dot) character

Explanation: in Linux, the period (dot) is short hand for the bash built in source. It will read and execute commands from a file in the current environment and return the exit status of the last command executed.

The .(dot) character is the first character for a file or directory names if they should not be displayed by commands such as ls unless specifically requested

4 0
3 years ago
Over the last ten years, what has caused the audience ratio of three major networks, CBS, NBC, and ABC from 90 percent to 60 per
Goryan [66]
D is your answer good luck
5 0
3 years ago
Use C++:
AveGali [126]

Answer:

result = pow(10,5);

Explanation:

A complete code in C++ with the necesary header file for the math class is given below:

#include <iostream>

//import the header file to use the power function

#include<cmath>

using namespace std;

int main()

{

   double base = 10.0;

   double result;

  //Use Power function to raise base to power of 5

   result = pow(10,5);

   //print out the result

   cout<<result;

   return 0;

}

5 0
2 years ago
Other questions:
  • What is a series of instructions or commands that a computer follows used to create software
    9·1 answer
  • What is the importance of Mathematical Modeling in the field of bioinformatics.
    8·1 answer
  • Write a function ngrams(n, tokens) that produces a list of all n-grams of the specified size from the input token list. Each n-g
    6·1 answer
  • What is the big-O performance estimate of the following function?
    15·2 answers
  • Do you agree that technology can be used to commit acts of violence ? Explain why or why not
    11·1 answer
  • Who has pad let and wants to talk
    15·2 answers
  • MATH PLZ HELP ITS DUE IN 4 MINUTES​
    6·2 answers
  • ¿por que hay peligros en internet?
    11·1 answer
  • Assume that Publication is the root class of an inheritance tree. You want to form a linked list of different publications in th
    12·1 answer
  • What is malware? What are some signs that malware may be impacting the performance of your computer? How can you avoid malware?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!