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
Ket [755]
4 years ago
8

Assignment Ahead of an expected drought this winter, the National Weather Service would like you to write a program that records

the rainfall totals for 5 California cities and calculates a some statistics on the data. They would like to use your program in their branch offices across the state, so it needs to be able to accept rainfall data for any 5 cities, specified by the user. Using values stored in arrays, write a program that does the following: 1. Prompts the user for the names of 5 California cities. You can use any 5 cities of your choosing. Here are some to help you get started: (note that some cities have spaces in their names, this should be allowed). 2. Prompts the user in a loop) to enter rainfall totals (in inches, as a decimal number) for each of the 5 cities. Validate the input so the rainfall must be re-entered if it is less than zero or greater than 100. 3. Using 3 value-returning functions, calculate the locations with the highest and lowest rainfall and the average rainfall across the 5 cities. 4. Output the 3 calculated values with a precision of 2 digits past the decimal point.
Engineering
1 answer:
Marat540 [252]4 years ago
6 0

Answer:

#include "stdafx.h"

#include <string>

#include <iostream>

#include <iomanip> //setprecision and fixed is located in this namespace

using namespace std;

const int Max = 5;

string Cities[Max];

double CitiesRainfall[Max];

int getIndexOfLowest(double[], int);

int getIndexOfHighest(double[], int);

double getAverage(double[], int);

void Menu();

void InputCities();

void InputCitiesRainfall();

void PrintOutput();

int main()

{

  InputCities();

  InputCitiesRainfall();

  PrintOutput();

  system("pause");

  return 0;

}

void InputCities()

{

  bool loop = false;

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

  {

      string city;

      do

      {

          cout << "Please enter city #" << i + 1 << ": ";

          getline(cin, city);

          if (city == "")

          {

              cout << "City cannot be empty!" << endl;

              loop = true;

          }

          else

          {

              loop = false;

          }

      } while (loop);

      Cities[i] = city;

  }

}

void InputCitiesRainfall()

{

  bool loop = false;

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

  {

      double rainfallTotal;

      do

      {

          cout << "Please enter the rainfall total for " << Cities[i] << ": ";

          cin >> rainfallTotal;

          if (rainfallTotal<0 || rainfallTotal>100)

          {

              cout << "Rainfall must be greater than 0 or less than 100." << endl;

              loop = true;

          }

          else

          {

              loop = false;

          }

      } while (loop);

      CitiesRainfall[i] = rainfallTotal;

  }

}

int getIndexOfLowest(double arr[], int size)

{

  int index = 0;

  int lowest = arr[0];

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

  {

      if (lowest>arr[i])

      {

          lowest = arr[i];

          index = i;

      }

  }

  return index;

}

int getIndexOfHighest(double arr[], int size)

{

  int index = 0;

  int highest = arr[0];

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

  {

      if (highest < arr[i])

      {

          highest = arr[i];

          index = i;

      }

  }

  return index;

}

double getAverage(double arr[], int size)

{

  double avg, total;

  avg = total = 0;

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

  {

      total += arr[i];

  }

  avg = total / size;

  return avg;

}

void PrintOutput()

{

  int highestRainfallIndex = getIndexOfHighest(CitiesRainfall, Max);

  cout << "The city with the highest rainfall is " << Cities[highestRainfallIndex] << "." << endl;

  int lowestRainfallIndex = getIndexOfLowest(CitiesRainfall, Max);

  cout << "The city with the lowest rainfall is " << Cities[lowestRainfallIndex] << "." << endl;

  cout << "The average rainfall across all cities is " << setprecision(2) << fixed << getAverage(CitiesRainfall, Max) << " inches." << endl;

}

Explanation:

You might be interested in
Conduct online research and write a short report on the origin and evolution of the meter as a measurement standard. Discuss how
valina [46]

Answer:

People have come up with all sorts of inventive ways of measuring length. The most intuitive are right at our fingertips. That is, they are based upon the human body: the foot, the hand, the fingers or the length of an arm or a stride.

In ancient Mesopotamia and Egypt, one of the first standard measures of length used was the cubit. In Egypt, the royal cubit, which was used to build the most important structures, was based on the length of the pharaoh’s arm from elbow to the end of the middle finger plus the span of his hand. Because of its great importance, the royal cubit was standardized using rods made from granite. These granite cubits were further subdivided into shorter lengths reminiscent of centimeters and millimeters.

piece of black rock with white Egyptian markings

Fragment of a Cubit Measuring Rod

Credit: Gift of Dr. and Mrs. Thomas H. Foulds, 1925

Later length measurements used by the Romans (who had taken them from the Greeks, who had taken them from the Babylonians and Egyptians) and passed on into Europe generally were based on the length of the human foot or walking and multiples and subdivisions of that. For example, the pace—one left step plus one right step—is approximately a meter or yard. (On the other hand, the yard did not derive from a pace but from, among other things, the length of King Henry I of England’s outstretched arm.) Mille passus in Latin, or 1,000 paces, is where the English word “mile” comes from.

And thus, the meter has and likely will remain so elegantly defined in these terms for the foreseeable future.

Explanation:

is this short enough

5 0
2 years ago
In a creep test, increasing the temperature will (choose the best answer) A. increase the instantaneous initial deformation B. i
Hitman42 [59]

Answer:

All of the above

Explanation:

firstly, a creep can be explained as the gradual deformation of a material over a time period. This occurs at a fixed load with the temperature the same or more than the recrystallization temperature.

Once the material gets loaded, the instantaneous creep would start off and it is close to electric strain. in the primary creep area, the rate of the strain falls as the material hardens. in the secondary area, a balance between the hardening and recrystallization occurs. The material would get to be fractured hen recrstallization happens.  As temperature is raised the recrystallization gets to be more.

8 0
3 years ago
Please read and answer each question carefully.
Klio2033 [76]

the answer is (c)

After the vehicle is involved in a car accident or fire

5 0
3 years ago
Water is stored in a tank which has vent open to the atmosphere. The water level is 1.0 m below the top the tank and the water i
sp2606 [1]

Answer:

6.99 x 10⁻³ m³ / s

Explanation:

Th e pressure difference at the two ends of the delivery pipe due to atmospheric pressure and water column will cause flow of water.

h = difference in the height of water column at two ends of delivery pipe

6 - 1 =  5 m

Velocity of flow of water

v = √2gh

= √ (2 x 9.8 x 5)

=  9.9 m /s

Volume of water flowing per unit time

velocity x cross sectional area

= 9.9 x 3.14 x .015²

= 6.99 x 10⁻³ m³ / s

7 0
3 years ago
Free brainlist because im new and i just want to but you have t friend me first
Amiraneli [1.4K]
Okay sure.









I’ll 1)chords
2)pulse
3)aerophone
4) the answer is C
5)rhythm

Pretty sure those are the answers
4 0
3 years ago
Other questions:
  • True or false? Don't break or crush mercury-containing lamps because mercury powder may be released.
    8·1 answer
  • What is the stress concentration factor of a shaft in torsion, where D=1.25 in. and d=1 in. and the fillet radius is, r=0.2 in.a
    7·1 answer
  • Represent the following sentence by a Boolean expression:
    11·1 answer
  • The fouling on the heat exchanger surfaces causes additional thermal resistance, thus decreases the heat transfer rate. a)- True
    11·1 answer
  • For a steel alloy it has been determined that a carburizing heat treatment of 14 h duration at 809°C will raise the carbon conce
    13·1 answer
  • How can statistical analysis of a dataset inform a design process
    8·1 answer
  • In an RL parallel circuit, VT = 240 V, R = 330 Ω, and XL = 420 Ω. What is the Apparent Power (VA)?
    9·1 answer
  • How does error detection take place
    8·1 answer
  • Technician A says the compressor is the dividing line of the refrigeration system, low- to high-side. Technician B says the expa
    6·1 answer
  • when discussing valve train components, technician a says stamped rocker arms are very strong and may be used in high-horsepower
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!