Weather Tracking Application
<p>The Application has to display temperatures for five cities. I can't get the lowest and highest temperature columns to display. I got the first three columns for the temperature readings to display along with the average temperature column, but can't get the fourth temperature reading column to display. In addition, I can't get the area average label to display the area average. Any ideas?</p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lab8practice1
{
  public partial class Form1 : Form
  {

    string[] strCities = {  "Troy",
                            "West Bloomfield",
                            "Farmington Hills",
                            "Brighton",
                            "Canton"};

    int[,] intTemperatures = new int[5, 3];


    public Form1()
    {
        InitializeComponent();
    }



    private void btnAddTemperature_Click(object sender, EventArgs e)
    {
        try
        {
            if (cmbCities.SelectedIndex &gt;= 0 &amp;&amp; cmbCities.SelectedIndex &lt;= 4)
            {
                if (intTemperatures[cmbCities.SelectedIndex, (int)nudReading.Value -1] == 0)
                {
                    intTemperatures[cmbCities.SelectedIndex, (int)nudReading.Value - 1] = Int32.Parse(txtTemperature.Text);
                }
                else
                {
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult result;
                    result = MessageBox.Show("Modify Temperature?", "Temperature already exists!", buttons);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        intTemperatures[cmbCities.SelectedIndex, (int)nudReading.Value - 1] = Int32.Parse(txtTemperature.Text);
                    }
                }
                displayTemperatures();


            }
            else
            {
                MessageBox.Show("Select a city!");
            }
        }
        catch (FormatException)
        {
            MessageBox.Show("Temperatures must be whole numbers!");
        }
    }

    private void displayTemperatures()
    {
        string strCities;
        lstTemperatures.Items.Clear();
        double[] dblAverages = new double[5];
        int intNonBlank = 0;
        double dblNonBlank = 0.0;
        int intMin = 150, intMax = 0, intTotal = 0;

        for (int g = 0; g &lt;= 4; g++)
        {
            intNonBlank = 0;
            for (int d = 0; d &lt;= 2; d++)
            {
                if (intTemperatures[g, d] != 0)
                {
                    dblAverages[g] += intTemperatures[g, d];
                    intNonBlank++;
                }
            }
            if (intNonBlank != 0)
            {
                dblAverages[g] /= intNonBlank;
            }
        }

        for (int g = 0; g &lt;= 4; g++)
        {
            for (int d = 0; d &lt;= 2; d++)
            {
                if (intTemperatures[g, d] != 0)
                {
                    intTotal += intTemperatures[g, d];
                    dblNonBlank++;
                }

                if (intTemperatures[g, d] &lt; intMin &amp;&amp; intTemperatures[g, d] != 0)
                {
                    intMin = intTemperatures[g, d];
                }

                if (intTemperatures[g, d] &gt; intMax)
                {
                    intMax = intTemperatures[g, d];
                }
            }
        }

        for (int g = 0; g &lt;= 4; g++)
        {
            strCities = " ";

            for (int d = 0; d &lt;= 2; d++)
            {
                if (intTemperatures[g, d] == 0)
                {
                    strCities += "          ";
                }
                else
                {
                    if (intTemperatures[g, d] == 103)
                    {
                        strCities += intTemperatures[g, d] + "       ";
                    }
                    else
                    {
                        strCities += intTemperatures[g, d] + "       ";
                    }
                }
            }

            if (dblAverages[g] == 0)
            {
                strCities += "             ";
            }
            else
            {
                if (dblAverages[g] == 140)
                {
                    strCities += dblAverages[g].ToString("f2") + "          ";
                }
                else
                {
                    strCities += dblAverages[g].ToString("f2") + "          ";
                }
            }

            lstTemperatures.Items.Add(strCities);
            lblAreaAverage.Text = dblAverages.ToString("f2");

        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        for (int i = 0; i &lt;= 4; i++)
        {
            cmbCities.Items.Add(strCities[i]);
            lstCities.Items.Add(strCities[i]);
        }
    }
  }
}
</code></pre>
