Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'ve been working on this for a week now and haven\'t made any progress. Please

ID: 3771265 • Letter: I

Question

I've been working on this for a week now and haven't made any progress.

Please help me write an application that enables you to randomly record water depths for 5 different locations at 0700 (7 a.m.), 1200 (12 p.m.), 1700 (5 p.m.), and 2100 (9 p.m.). The locations are Surf City, Solomons, Hilton Head, Miami, and Savannah.

For ease of input, you may want to code the locations (i.e. Surf City = 1, Solomons = 2, etc.) and code the times the same way. If the same location and time are entered more than once, store the last value entered into the array.

After the data is entered, display a table showing the individual data in rows and columns as well as the average depth at each location and the average depth by time period.

I believe the main logic should look something like this:

        public static void Main(string[] args)
        {
            double[,] waterDepth = new Double[6, 5];
            string[] location = { "Surf City", "Solomons", "Hilton Head", "Miami", "Savannah" };
            string[] time = { "7:00 A.M.", "12:00 P.M.", "5:00 P.M.", "9:00 P.M." };

            InitializeArray(waterDepth);
            GetWaterDepths(waterDepth, location, time);
            FindAvgDepthByLocation(waterDepth);
            FindAvgDepthByTime(waterDepth);
            DisplayTable(waterDepth, location, time);
            Console.ReadKey();
        }

Explanation / Answer

using System;

namespace water
{
    class Program
    {
        static void InitializeArray(double[,] waterDepth)
        {
            for(int i=0;i<5;i++)
            {
                for(int j=0;j<6;j++)
                {
                    waterDepth[i,j]=0.0;
                }
            }
            Console.WriteLine("Array Initialized");
        }

        static void GetWaterDepths(double[,] waterDepth, string[] location, string[] time)
        {
            for(int i=0;i<waterDepth.GetLowerBound-1;i++)
                {
                for(int j=0;j<waterDepth.GetUpperBound-1;j++)
                    {
                    Console.WriteLine(time[i]+" @"+location[j]);
                    waterDepth[i,j]=Double.TryParse(Console.ReadLine());
                    }
                }
            Console.WriteLine("Water depth data read finished");
        }

        static void FindAvgDepthByLocation(double[,] waterDepth,string[] location)
        {
            double[]average=new double[waterDepth.GetUpperBound];
            for(int i=0;i<waterDepth.GetUpperBound-1;i++)
                {
                average[i]=0;
                for(int j=0;j<waterDepth.GetLowerBound-1;j++)
                    {
                        average[i]+=waterDepth[i,j];
                    }
                average[i]/=(waterDepth.GetLowerBound-1);
                }
            Console.WriteLine("Average water Depth by location");
            for(int i=0;i<waterDepth.GetUpperBound-1;i++)
                {
                Console.WriteLine(location[i]+"    "+average[i]);
                }
        }

        static void FindAvgDepthByTime(double[,] waterDepth, string[] time)
        {
            double[]average=new double[waterDepth.GetLowerBound];
            for(int i=0;i<waterDepth.GetLowerBound-1;i++)
                {
                average[i]=0;
                for(int j=0;j<waterDepth.GetUpperBound-1;j++)
                    {
                        average[i]+=waterDepth[i,j];
                    }
                average[i]/=(waterDepth.GetUpperBound-1);
                }
            Console.WriteLine("Average water Depth by Time");
            for(int i=0;i<waterDepth.GetLowerBound-1;i++)
                {
                Console.WriteLine(time[i]+"    "+average[i]);
                }
        }

        static void DisplayTable(double[,] waterDepth, string[] location, string[] time)
        {
            Console.Write(" time/loc");
            for(int i=0;i<location.GetLength;i++)
            {
                Console.Write(location[i]+"   ");
            }
            Console.WriteLine("");
            for(int i=0;i<waterDepth.GetLowerBound-1;i++)
            {
                Console.Write(time[i]);
                for(int j=0;j<waterDepth.GetUpperBound-1;j++)
                {
                    Console.Write(waterDepth[i][j]+"    ");
                }
                Console.WriteLine("");
            }
        }

        public static void Main(string[] args)
        {
            double[,] waterDepth = new Double[6, 5];
            string[] location = { "Surf City", "Solomons", "Hilton Head", "Miami", "Savannah" };
            string[] time = { "7:00 A.M.", "12:00 P.M.", "5:00 P.M.", "9:00 P.M." };
            InitializeArray(waterDepth);
            GetWaterDepths(waterDepth, location, time);
            FindAvgDepthByLocation(waterDepth,location);
            FindAvgDepthByTime(waterDepth,time);
            DisplayTable(waterDepth, location, time);
            Console.ReadKey();
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote