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 8380513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:28:38+00:00 2026-06-09T16:28:38+00:00

I have this an assignment where the user has to enter in a name,

  • 0

I have this an assignment where the user has to enter in a name, then a score, and repeat that process until they are done, press Q, and then the array will show the names and scores, then give an average of all of those scores. What I have right now is this.

    static void inputPartInformation(string[] pl, double[] sc)
    {

        int i = 0;

        do
        {
            Console.Write("Enter The Player's Name: ");

            pl[i] = Console.ReadLine();


            Console.Write("Enter Their Score: ");

            sc[i] = double.Parse(Console.ReadLine());

        }
        while (pl[i++].CompareTo("Q") != 0);

    }


    static void displayParts(string[] pl, double[] sc)
    {
        int i = 0;
        while (pl[i].CompareTo("Q") != 0)
        {
            Console.WriteLine("{0,15}{1,6}", pl[i], sc[i]);
            ++i;
        }

    }

    static void Main(string[] args)
    {

        String[] players = new String[100];

        double[] scores = new double[100];

        inputPartInformation(players, scores);



        displayParts(players, scores);


        double average = scores.Average();
        Console.WriteLine("The Average is: {0}", average);



        Console.ReadLine();

    }

When I try to average the scores, it doesn’t come out properly.

  • 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-06-09T16:28:40+00:00Added an answer on June 9, 2026 at 4:28 pm

    The problem is with the call of Average: you are averaging everything, not everything up to the "Q" in the corresponding names position. You are adding together all these zeros in the scores part to which you did not write, and then divide it by 100 – the length of the entire array.

    The easiest way to address this issue is to return the position of the "Q" entry from the inputPartInformation method:

    var count = inputPartInformation(players, scores);
    

    Now you can use LINQ’s Take function to get the correct average:

    double average = scores.Take(count).Average();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, I have this assignment and I have to prompt the user for data
This is uni assignment and I have already done some stuff. Please go to
I have an Attendance model that allows the user to enter a starting, ending
I have written a user control that captures some user input and has a
I have this homework assignment where the user is asked to input numbers and
I have a user control with a UniformGrid that has a number of Buttons.
This is a homework assignment, I have to write a program that reads a
so we're doing this assignment at Uni and i have a serious craving to
I have added this fix https://gist.github.com/2382288 for protect all fields against mass assignment in
Can I optimize the class assignment here at all? I have to do this

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.