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
Protocols at which layer of the OSI model have the primary function of moving datagrams through an internetwork connected by rou
Vladimir [108]

Answer:

"Network layer" is the correct answer to the given question .  

Explanation:

The network layer is interconnected with different networks by providing permission to the network. This job is done by sending the packets in the network. The main aim of the network layer is to provide the logical addressing, routing, and fragmentation of packets.

The network layer is the layer of the OSI model whose primary function is moving the packets or datagrams in the internetwork which is connected by the routers.  

5 0
3 years ago
What is software and explain the five types of software
rewona [7]

Question: What is software and explain the five types of software

Explanation: The system software which is controlled and managed by the use of set of instructions and programs is called software.

Ex: Windows 7/8/10/xp etc...

the  types of software are'

system software and application software

Android.

CentOS.

iOS.

Linux.

Mac OS.

MS Windows.

Ubuntu.

Unix.

5 0
2 years ago
Read 2 more answers
Why does a HTML seen to work even when its broken? why does the code sometimes turn pink?
OverLord2011 [107]

the reason HTML seems to work even if it has syntax errors is due to browser having built in ways to parse the code meaning it will still show but most likely look way different then you would want.

the code may turn pink due to syntax errors

5 0
3 years ago
Write Python code to save the data to a MongoDB collection:Import json module to parse JSON dataImport MongoClient from pymongo
Zigmanuir [339]

Answer:

Explanation:

The objective of this task is to compute a program that involves the usage of Python code to save the data to MongoDB and to query  the database.

Due to the error that occur which makes me to be unable to submit this answer, I've created a word document instead and the attached file can be found below.

Thanks!

Download docx
8 0
2 years ago
Review 03 diagnostic and troubleshooting skills including data gathering methods and techniques.
d1i1m1o1n [39]

The kinds and ways to improve your diagnostic and troubleshooting skills are:

  • Be Relax and never panic when you encounter it.
  • Know everything about your computer.
  • Look for solutions and clues and state them down.
  • Find out the repeatability.

<h3>What is diagnostic and troubleshooting?</h3>

Diagnosing is known to be the act of finding out the root cause of any issue through an act of elimination but troubleshooting is known to be the act of fixing of the problem after diagnosis is said to have been carried out.

Therefore, The kinds and ways to improve your diagnostic and troubleshooting skills are:

  • Be Relax and never panic when you encounter it.
  • Know everything about your computer.
  • Look for solutions and clues and state them down.
  • Find out the repeatability.

Learn more about troubleshooting skills from

brainly.com/question/14983884

#SPJ1

6 0
1 year ago
Other questions:
  • A brick weighs 26 N. Measured underwater, it weighs 11 N.
    10·1 answer
  • Which element of the security policy framework requires approval from upper management and applies to the entire organization?A.
    5·1 answer
  • The layout gallery displays 10 slide layouts with a variety of placeholders to define text and content positioning and formattin
    13·1 answer
  • How to engage more underrepresented and under resourced students in stem programs?
    10·1 answer
  • State two functions of windows environment​
    9·1 answer
  • What is computer Network?​
    10·1 answer
  • 5. ADD A STATEMENT OR STATEMENTS to the program on the following page (including constant and/or variable declarations if you wa
    6·1 answer
  • Compare entertainment applications to social media applications.
    5·2 answers
  • What are some benefits of 3-D printing?
    9·1 answer
  • The best way to help prevent a system from a worm attack is to use anti-virus software anti-malware software a firewall a router
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!