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]
3 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]3 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
The liquid-phase reaction:
OLEGan [10]

Answer:

attached below

Explanation:

4 0
3 years ago
2) The switch in the circuit below has been closed a long time. At t=0, it is opened.
saul85 [17]

Answer:

  il(t) = e^(-100t)

Explanation:

The current from the source when the switch is closed is the current through an equivalent load of 15 + 50║50 = 15+25 = 40 ohms. That is, it is 80/40 = 2 amperes. That current is split evenly between the two parallel 50-ohm resistors, so the initial inductor current is 2/2 = 1 ampere.

The time constant is L/R = 0.20/20 = 0.01 seconds. Then the decaying current is described by ...

  il(t) = e^(-t/.01)

  il(t) = e^(-100t) . . . amperes

8 0
3 years ago
11–17 A long, thin-walled double-pipe heat exchanger with tube and shell diameters of 1.0 cm and 2.5 cm, respectively, is used t
lana [24]

Answer:

the overall heat transfer coefficient of this heat exchanger is 1855.8923 W/m²°C

Explanation:

Given:

d₁ = diameter of the tube = 1 cm = 0.01 m

d₂ = diameter of the shell = 2.5 cm = 0.025 m

Refrigerant-134a

20°C is the temperature of water

h₁ = convection heat transfer coefficient = 4100 W/m² K

Water flows at a rate of 0.3 kg/s

Question: Determine the overall heat transfer coefficient of this heat exchanger, Q = ?

First at all, you need to get the properties of water at 20°C in tables:

k = 0.598 W/m°C

v = 1.004x10⁻⁶m²/s

Pr = 7.01

ρ = 998 kg/m³

Now, you need to calculate the velocity of the water that flows through the shell:

v_{w} =\frac{m}{\rho \pi (\frac{d_{2}^{2}-d_{1}^{2}  }{4} )} =\frac{0.3}{998*\pi (\frac{0.025^{2}-0.01^{2}  }{4}) } =0.729m/s

It is necessary to get the Reynold's number:

Re=\frac{v_{w}(d_{2}-d_{1}) }{v} =\frac{0.729*(0.025-0.01)}{1.004x10^{-6} } =10891.4343

Like the Reynold's number is greater than 10000, the regime is turbulent. Now, the Nusselt's number:

Nu=0.023Re^{0.8} Pr^{0.4} =0.023*(10891.4343)^{0.8} *(7.01)^{0.4} =85.0517

The overall heat transfer coefficient:

Q=\frac{1}{\frac{1}{h_{1} }+\frac{1}{h_{2} }  }

Here

h_{2} =\frac{kNu}{d_{2}-d_{1}} =\frac{0.598*85.0517}{0.025-0.01} =3390.7278W/m^{2}C

Substituting values:

Q=\frac{1}{\frac{1}{4100}+\frac{1}{3390.7278}  } =1855.8923W/m^{2} C

5 0
3 years ago
The purpose of pasteurizing milk is to
katen-ka-za [31]

Answer:

i think it c

Explanation:

6 0
3 years ago
Read 2 more answers
A three-point bending test is performed on a glass specimen having a rectangular cross section of height d 5 mm (0.2 in.) and wi
Anon25 [30]

Answer:

The flexural strength of a specimen is = 78.3 M pa

Explanation:

Given data

Height = depth = 5 mm

Width = 10 mm

Length L = 45 mm

Load = 290 N

The flexural strength of a specimen is given by

\sigma = \frac{3 F L}{2 bd^{2} }

\sigma = \frac{3(290)(45)}{2 (10)(5)^{2} }

\sigma = 78.3 M pa

Therefore the flexural strength of a specimen is = 78.3 M pa

4 0
3 years ago
Other questions:
  • Modify any of the previous labs which would have crashed when non-numeric data was entered by adding exception handling so that
    8·1 answer
  • The lab technician you recently hired tells you the following: Boss, an undisturbed sample of saturated clayey soil was brought
    6·1 answer
  • 5. Switch a in the circuit has been open for a long time and switch b has been closed for a long time. Switch a is closed at t =
    13·1 answer
  • How should employees talk to clients)
    9·1 answer
  • Compact fluorescent bulbs are much more efficient at producing light than are ordinary incandescent bulbs. They initially cost m
    11·1 answer
  • A 3-m-high, 11-m-wide rectangular gate is hinged at the top edge at A and is restrained by a fixed ridge at B. Determine the hyd
    12·1 answer
  • What are the factors of production in business? Land, labor, and capital land, capital, and interest land, labor, and customer b
    10·2 answers
  • A material point in equilibrium has 1 independent component of shear stress in the xz plane. a)True b)- False
    6·1 answer
  • Air expands through a turbine operating at steady state. At the inlet p1 = 150 lbf/in^2, T1 = 1400R and at the exit p2 = 14.8 lb
    10·1 answer
  • Why is it important to cut all the way through an electrical wire on the first try?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!