Question: I'm having difficulty looping this program back to the beginning after That number is outside the boundary of the List using System; using static System.Console;

I'm having difficulty looping this program back to the beginning after "That number is outside the boundary of the List"

using System; using static System.Console;

namespace Program { class Program { static void Main() { int[] nums = { 7, 6, 3, 2, 1, 8, 4, 5 }; int choice = 0; const int EXIT = 999; int x; int positionChoice; while (choice != EXIT) { WriteLine("Choose One:"); WriteLine("1 : to view the list in order first to last"); WriteLine("2 : to view the list in order last to first"); WriteLine("3 : choose a specific position to view"); WriteLine("{0} to exit this program", EXIT); Write(""); choice = Convert.ToInt32(ReadLine());

if (choice 3 && choice != EXIT)) ;

switch (choice) { case 1: case 2: WriteLine("--------------------------------"); if (choice == 1) WriteLine("List in Order from First to Last"); else { WriteLine("List in Order from Last to First"); Array.Reverse(nums); } for (x = 0; x 8) { WriteLine("--------------------------------"); WriteLine("What position from 1 to 8 would you like to see: "); positionChoice = Convert.ToInt32(ReadLine()); if (positionChoice 8) WriteLine("That number is outside the boundary of the List", EXIT); } WriteLine(); WriteLine("The List Element in position {1} --> {0}", nums[positionChoice] + 1, positionChoice); break; case EXIT: WriteLine(""); break; default: WriteLine("** Invalid Entry ** - Must choose either 1, 2, 3, or {0} to exit", EXIT); break;

} WriteLine(); } } } }

The end result should look EXACTLY like this:

I'm having difficulty looping this program back to the beginning after "That

OSYCAWINDOWSlsystem321cmd.exe hoose one: 1 to view the list in order first to last 2 to view the list in order last to first 3 choose a specific position to view 999 to exit this program List in Order from First to Last 7 6 3 2 18 4 5 Choose one: 1 to view the list in order first to last 2 to view the list in order last to first 3 choose a specific position to view 999 to exit this program List in Order from Last to First 5 4 8 1 2 3 6 7 Choose one: 1 to view the list in order first to last 2 to view the list in order last to first 3 choose a specific position to view 999 to exit this program 9 Invalid EntryMust choose either 1, 2, 3 or 999 to exit Choose one: 1 to view the list in order first to last 2 to view the list in order last to first 3 choose a specific position to view 999 to exit this program hat position from 1 to 8 would you like to see: The List Element in position 4 - 2 Choose one: 1 to view the list in order first to last 2 to view the list in order last to first 3 choose a specific position to view 999 to exit this program hat position from 1 to 8 would you like to see: That number is outside the boundary of the List hoose one 1 to view the list in order first to last 2 to view the list in order last to first 3 choose a specific position to view 999 to exit this program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!