Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6665691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:44:59+00:00 2026-05-26T02:44:59+00:00

So, I am trying to make a console program that analyzes data(well kind of).

  • 0

So, I am trying to make a console program that analyzes data(well kind of). The problem is when I go to print the median it tells me it is unassigned(well the debugger says this actually). What did I do wrong?
using System;

using System;

class midpointFormula
{
    static void Main()
    {
    double min, max, range, median, quartile1, quartile3, internalQuartileRange, IQR15;
    int dataPoints, dataPoints1, count, count1;
    double[] dataSet;
    bool isEven;

    count = 0;

    Console.WriteLine("This program allows you to find several diffrent values from the data");
    Console.Write("Please enter the amount of data points you would like to use: ");

    dataPoints = int.Parse(Console.ReadLine());
    dataPoints1 = dataPoints - 1;

    dataSet = new double[dataPoints];

    #region Enter Data
    while (count < dataPoints)
    {

        count1 = count + 1;

        Console.Write("Please enter the {0} datapoint: ", count1);

        dataSet[count] = double.Parse(Console.ReadLine());

        ++count;

    }
    #endregion

    min = dataSet[0];
    max = dataSet[dataSet.Length - 1];
    range = max - min;


    #region Even Check
    if (dataPoints % 2 == 0)
    {
    isEven = true;
    }
    else
    {
    isEven = false;
    }
    #endregion

    if (isEven == true)
    {
        int medianPoint;

        medianPoint = (dataPoints / 2) - 1;

        median = dataSet[medianPoint];


    }
    else


    #region Output
    Console.WriteLine("Minimum is : {0}", min);
    Console.WriteLine("Maximum is : {0}", max);
    Console.WriteLine("Range is   : {0}", range);
    Console.WriteLine("Median is  : {0}", median);
    #endregion

    Console.ReadKey();
}

}

Note: Yes, I know if there is an uneven amount of datapoints it will not calculate the data points, I am still working on that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:45:00+00:00Added an answer on May 26, 2026 at 2:45 am

    Because median is only assigned a value if isEven is true. If it is not, it will be unitialized. Since it is never acceptable to use a variable that even might be unassigned, the compiler prohibits it.

    P.S. It’s not the debugger that is reporting this error, it is the compiler.

    P.P.S. What is going on with your else statement? — based on indent it looks like an incomplete thought and an obvious bug. (Console.WriteLine("Minimum is : {0}", min); will only run if isEven is false, but the rest of those statements will run since they’re not enclosed by braces.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a console app that would monitor some process and restart
I'm trying to make a little console application that is able to deal with
Trying to make a custom :confirm message for a rails form that returns data
This one is killing me. I'm trying to make a simple console app that
I am trying to make a simple phone directory program in windows console application.
I'm trying to make a program that can turn off the monitor with a
I'm trying to make a C# console app that adds messages to a queue.
I'm trying to make a program that check the ISBN number and sees if
So I'm trying to make a simple C# console app that simply queries a
I'm trying to make my console application into a winforms application. The console version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.