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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:08:52+00:00 2026-06-03T13:08:52+00:00

I am required to write a program that reads data into an array of

  • 0

I am required to write a program that reads data into an array of type int. Valid values are from 0 to 10. your program should determine how many values were input. Output a list of distinct entries and a count of how many times that entry occurred.”

I’m having trouble with the bolded part, this is what i have so far…

static void Main(string[] args)
{
    Console.WriteLine("How many scores will you enter?");

    int total = 0;
    string inValue;
    string Size = Console.ReadLine();
    int arraySize = Convert.ToInt32(Size);
    int [] ScoreArray = new int [arraySize];

    for (int i = 0; i < ScoreArray.Length; i++)
    {

        Console.Write("Enter a Number between 0 and 10, #{0}: ", i + 1);
        inValue = Console.ReadLine();
        ScoreArray[i] = Convert.ToInt32(inValue);

        total += ScoreArray[i];
    }

    Console.WriteLine("Number of scores entered: " + arraySize);
    Console.Read();
}
  • 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-03T13:08:53+00:00Added an answer on June 3, 2026 at 1:08 pm

    I think the key here is valid values are between 0-10. I would use the array index to store each value itself. For example, if you process the value 5, increment values[5].

    So first you’d initialize an array like:

    int[] values = new int[11]; //Values 0-10
    

    Then, loop until the user just enters blank:

    while(true)
    {
       string inValue = Console.ReadLine();
       if(String.IsNullOrEmpty(inValue)) break;
    
       values[Convert.ToInt32(inValue)]++; //Bounds checking would be nice here
    }
    

    You can then display a sorted distinct list by looping through the array once and printing out any index with a value greater than 0:

    for(int i = 0; i < values.length; i++)
    {
       if(values[i] > 0)
       {
          Console.WriteLine("Value {0} was entered {1} time(s)..", i, values[i]);
       }
    }
    

    This is most likely what your professor is looking for. I have not tested the code above, that’s your job 🙂

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

Sidebar

Related Questions

I'm working on a program for class that reads data from a file, the
I have to write a program that is required to run several other programs
I have a PHP program that reads from the database and generated formatted sheets.
I am required to write a script that would download a file (based on
I'm required to write a JCE provider. I have learned that I need to
write a script that takes two optional boolean arguments,--verbose‚ and ‚--live, and two required
I would like to write a small piece of program that launches threads, consumes
I'm trying to write a program that takes input of - hexadecimals, octals, and
I'm trying to write a program that will change a particular GUID in a
I'm trying to create a program that reads ps and outputs the pid and

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.