I asked this once before but it came up incorrect somehow so I'll submit this one again. Write a program in C# named ArrayDemo that stores an array of 10 integers. (Note that the array is created for you and does not need to be changed.) Until the user enters a sentinel value, allow the user four options: (1) to view the list in order from the first to last position in the stored array (2) to view the list in order from the last to first position (3) to choose a specific position to view (4) to quit the application. -------- using System; using static System.Console; class ArrayDemo {    static void Main()    {        int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1};        // Write your main here    }   }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I asked this once before but it came up incorrect somehow so I'll submit this one again. Write a program in C# named ArrayDemo that stores an array of 10 integers. (Note that the array is created for you and does not need to be changed.)

Until the user enters a sentinel value, allow the user four options:

(1) to view the list in order from the first to last position in the stored array

(2) to view the list in order from the last to first position

(3) to choose a specific position to view

(4) to quit the application.

--------

using System;
using static System.Console;
class ArrayDemo
{
   static void Main()
   {
       int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1};
       // Write your main here
   }  
}
The image contains a C# program for managing an array and allowing user interaction through a console application. Below is the transcribed code and explanation:

```csharp
using System;
using static System.Console;
class ArrayDemo
{
    static void Main()
    {
        int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1};
        Console.WriteLine(" 1. to view the list in order from the first to last position in the stored array\n 2. to view the list in order from the last to first\n 3. to choose a specific position to view\n 4. to quit the application.\n");
        while(true){
            Console.WriteLine("Enter your choice from 1 to 4");
            int c = Convert.ToInt32(Console.ReadLine());
            if(c==1){
                Console.WriteLine("Array from the first to last position is : ");
                for(int i=0;i<10;i++)
                    Console.WriteLine(nums[i]);
            }
            else if(c==2){
                Console.WriteLine("Array from the last to first position is : ");
                for(int i=9;i>=0;i--)
                    Console.WriteLine(nums[i]);
            }
            else if(c==3){
                Console.WriteLine("Enter array position or index to view : ");
                int index = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Array element at given index is : ");
                Console.WriteLine(nums[index]);
            }
            else if(c==4){
                Environment.Exit(0);
            }
        }
    }
}
```

**Program Explanation:**

- **Import Libraries:**
  - The program uses the `System` namespace which provides essential classes and base classes for common operations. It also uses static system functionality for Console operations.

- **Class Definition:**
  - The class `ArrayDemo` contains the `Main` method which serves as the entry point of the program.

- **Array Initialization:**
  - An integer array `nums` is initialized with values `{7, 6, 3, 2, 10, 8, 4, 5, 9, 1}`.

- **User Menu:**
  - The application provides a user menu with options:
    1. View the array from first to last index.
    2. View the array from last
Transcribed Image Text:The image contains a C# program for managing an array and allowing user interaction through a console application. Below is the transcribed code and explanation: ```csharp using System; using static System.Console; class ArrayDemo { static void Main() { int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1}; Console.WriteLine(" 1. to view the list in order from the first to last position in the stored array\n 2. to view the list in order from the last to first\n 3. to choose a specific position to view\n 4. to quit the application.\n"); while(true){ Console.WriteLine("Enter your choice from 1 to 4"); int c = Convert.ToInt32(Console.ReadLine()); if(c==1){ Console.WriteLine("Array from the first to last position is : "); for(int i=0;i<10;i++) Console.WriteLine(nums[i]); } else if(c==2){ Console.WriteLine("Array from the last to first position is : "); for(int i=9;i>=0;i--) Console.WriteLine(nums[i]); } else if(c==3){ Console.WriteLine("Enter array position or index to view : "); int index = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Array element at given index is : "); Console.WriteLine(nums[index]); } else if(c==4){ Environment.Exit(0); } } } } ``` **Program Explanation:** - **Import Libraries:** - The program uses the `System` namespace which provides essential classes and base classes for common operations. It also uses static system functionality for Console operations. - **Class Definition:** - The class `ArrayDemo` contains the `Main` method which serves as the entry point of the program. - **Array Initialization:** - An integer array `nums` is initialized with values `{7, 6, 3, 2, 10, 8, 4, 5, 9, 1}`. - **User Menu:** - The application provides a user menu with options: 1. View the array from first to last index. 2. View the array from last
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education