+ 2

Help with Exceptions handling

In the following exercise I am missing something that until now I don't know what it is. Please can you help me with this. A tour operator offers holiday packages in England, Spain, Italy, Portugal and France. The program you are given defines an array with those options and takes the number N as input. Write a program to generate the package option with index N. If the number is out of range, the program should generate "Wrong number". Regardless of the option results, the program should generate "Goodbye" at the end. Input example two Output example Italy Goodbye. This is my code: https://code.sololearn.com/cTmPLO6LCD4q/?ref=app

9th Jul 2021, 1:44 AM
Alex NarvĂĄez
Alex NarvĂĄez - avatar
5 Answers
+ 2
you don't use input value to output the result but hardcode the index 2 (wich is only an example input)... do: Console.WriteLine(tours[choice]);
9th Jul 2021, 1:47 AM
visph
visph - avatar
+ 3
Console.WriteLine(tours[choice]);
9th Jul 2021, 1:45 AM
Simba
Simba - avatar
+ 1
Well thank you very much. Only that was missing. I am very grateful Simba
9th Jul 2021, 1:48 AM
Alex NarvĂĄez
Alex NarvĂĄez - avatar
+ 1
Thank you very much for that detail. I already understood better thanks to your help visph
9th Jul 2021, 1:50 AM
Alex NarvĂĄez
Alex NarvĂĄez - avatar
- 1
Alex NarvĂĄez I usually take the time to explain before providing the correction, as it seems to me more helpful for learning purpose ^^ (so, I didn't understand why quick Simba answer deserve the best answer much more than mine ;P)
9th Jul 2021, 1:52 AM
visph
visph - avatar