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
Rear axles are usually lubricated by the same gear oil that lubricates the differential. True or false
KIM [24]

Answer:

true

Explanation:

8 0
2 years ago
An electrical current of 700 A flows through a stainlesssteel cable having a diameter of 5 mm and an electricalresistance of 610
KatRina [158]

Answer:

778.4°C

Explanation:

I = 700

R = 6x10⁻⁴

we first calculate the rate of heat that is being transferred by the current

q = I²R

q = 700²(6x10⁻⁴)

= 490000x0.0006

= 294 W/M

we calculate the surface temperature

Ts = T∞ + \frac{q}{h\pi Di}

Ts = 30+\frac{294}{25*\frac{22}{7}*\frac{5}{1000}  }

Ts=30+\frac{294}{0.3928} \\

Ts =30+748.4\\Ts = 778.4

The surface temperature is therefore 778.4°C if the cable is bare

6 0
3 years ago
Which allows a user to run applications on a computing device? Group of answer choices Application software CSS Operating system
sveticcg [70]

Answer:

The operating system

Explanation:

The job of the operating system is to manage system resources allowing the abstraction of the hardware, providing a simple user interface for the user.  The operating system is also responsible for handling application's access to system resources.

For this purpose, the operating system allows a user to run applications on their computing device.

Cheers.

4 0
3 years ago
Write down the types of the Hydraulic Cylinders?
nirvana33 [79]

Answer:

There are following type of hydraulic cylinders

1.Single acting

2.Double acting

3.Single acting spring loaded

4.Non differential type

5.Ram type

6.Piston type

7.Actuating type

8.Telescopic type

4 0
4 years ago
The variation of the pressure of a fluid with density at constant temperature is known as the _____.
qaws [65]

The variation of the pressure of a fluid with density at constant temperature is known as the coefficient of compressibility.

<h3>What is a compressor?</h3>

A compressor can be defined as a mechanical device that is designed and developed to provide power to refrigerators, air conditioners, and other heating or cooling mechanical devices (engines), especially by increasing the pressure on air or other applicable gases.

In an isothermal process, the coefficient of compressibility is also known as isothermal compressibility or compressibility and it refers to a measure of the variation of the pressure and relative volume of a fluid with density at constant temperature.

Read more on coefficient of compressibility here: brainly.com/question/25237713

#SPJ1

7 0
2 years ago
Other questions:
  • All areas of the country use a BAC of 0.100.10 ​g/dL as the legal intoxication level. Is it possible that the mean BAC of all dr
    15·1 answer
  • Technician A says that as wheelbase becomes shorter in a highway truck, its resistance to yaw is
    14·1 answer
  • The voltage in a series circuit is being increased from 12 volts to 24 volts.
    6·1 answer
  • In the carbon cycle, how is carbon removed from the atmosphere?
    10·1 answer
  • Amy needs to create an architectural design for a charitable foundation. Which design principle element can Amy use to depict ca
    12·1 answer
  • Determine the maximum weight of the flowerpot that can besupported without exceeding a cable tension of 50 lb in eithercable AB
    15·1 answer
  • Steep safety ramps are built beside mountain highway to enable vehichles with fedective brakes to stop safely. a truck enters a
    14·1 answer
  • It is the responsibility of every employee to ensure that tools are used ____ and____.
    13·1 answer
  • Which of the following explains the main reason to cut a piece of wood on the outside of the measurement mark?
    13·1 answer
  • Explain why it is important to model the context of a system that is being developed. Give two examples of possible errors that
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!