Homework help RRS feed

  • Question

  • need help with these questions

    Part A

    Develop a C# program that initializes an array called "numbers" consisting of the number of elements that the user asks for. Then ask the user to enter values between 0 and 10 for each element. If the user an invalid value (i.e., less than zero or more than 10), prompt them to enter it again. Then display the histogram of the array with an * representing the value of each element of the array. For example, if the array contained five elements with the following values {2, 3, 0, 5, 1}, then the output would look like this:

    Element 1 **

    Element 2 ***

    Element 3

    Element 4 *****

    Element 5 *

    Part B

    Develop a C# application that counts the number of times a digit appears in a telephone number. Your program should create an array of size 10 that will hold the count of each digit. Read a telephone number from the keyboard as a string. Examine each character in the number and increment the appropriate count in the array. Display the content of the array.

    Monday, March 18, 2019 1:34 AM

All replies

  • You should show what you've figured out so far, and which part you're stuck on instead of just asking for solution.
    Monday, March 18, 2019 2:05 AM
  • Hi

    Thank you for posting here.

    Based on your description, you want to develop two c# applications that you needed to complete.

    You could try the following code.

    static void Main(string[] args)
                int[] numbers;
                List<int> list = new List<int>();
                   for (int i = 0; i < 5; i++)
                     Console.WriteLine("please input a number");
                find: int a = Convert.ToInt32(Console.ReadLine());
                      if (a >= 0 && a <= 10)
                            Console.WriteLine("please input an correct number");
                            goto find;
              int n = 1;
                foreach (int item in numbers)
                    Console.Write("Element" + n.ToString());
                }            //part2
                Console.WriteLine("please input telephone number");
                string s = Console.ReadLine();
                char[] c = s.ToCharArray();
                var cc = c.GroupBy(e => e).OrderByDescending(e => e.Count()).ToList();
                for (int i = 0; i < cc.Count; i++)
                    Console.WriteLine("{0} occurs\t{1} times", cc[i].Key.ToString(), cc[i].Count().ToString());
            static void change(int n)
                Console.Write("Element" + n.ToString());
                for (int i = 0; i <n; i++)


    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, March 18, 2019 9:03 AM
  • Just want to suggest that "don't post direct solution to homework problem", especially this type which just post the whole question here, without any effort shown to try digest the question.

    It would be better if you can at least withhold the answer until some effort is shown, because more often than not, they'll just copy the answer and never return.

    This will make our education system much more difficult to eliminate those who can't even "ask correct question" and will harm our ecosystem of software development.

    Monday, March 18, 2019 10:01 AM
  • I agree with cheong00's observation about homework questions.

    The VB.Net forum has a sticky post about the subject that, in my opinion, is worth reading.

    Monday, March 18, 2019 1:47 PM