Answer to Question #250916 in C# for Plea

Question #250916

Design wrapper classes about program in C# to read n number of values in an array and display it in reverse order. thank you in advance


1
Expert's answer
2021-10-13T16:58:41-0400
using System;


namespace Questions
{
    class Program
    {
        class Array
        {
            private int n;
            private double[] values;


            public Array(int n)
            {
                this.n = n;
                values = new double[n];
            }


            public void InputValues()
            {
                for(int i = 0; i < n; i++)
                {
                    Console.Write(string.Format("Enter number #{0}: ",i+1));
                    values[i] = double.Parse(Console.ReadLine());
                }
            }


            public void PrintInReverseOrder()
            {
                for (int i = n - 1; i >= 0; i--)
                    Console.Write(values[i] + " ");
            }
        }
        static void Main()
        {
            Console.Write("n = ");
            int n = int.Parse(Console.ReadLine());
            Array array = new Array(n);


            array.InputValues();
            Console.WriteLine();


            Console.Write("Reverse order: ");
            array.PrintInReverseOrder();


            Console.WriteLine();
            Console.ReadKey();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS