Ive got this code for a program that lets you choose weather to find the average of 10 numbers or to find the volume of a sphere or cube, but I need help with adding try, catch, and throw statements to it in any way it would work for example, if you enter a letter instead of a number where it asks for a value, could it be made so when you press enter after inputting a letter, you get a warning message and it asks for the previous variable to be inputted as an integer? it doesn't have to be exactly like that, but if you can help me to add try, catch, and finally in any way, you will be helping me out alot... Here is the code that I need to add this to,
Module Algorithm Sub Main() Dim enter As String Console.WriteLine("If you want to get the average of 10 numbers, enter 1") Console.WriteLine("If you want to find the volume of a cube or sphere, enter 2") enter = Console.ReadLine If enter = 1 Then Dim first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, average As Double Console.Write("Enter first value: ") first = Double.Parse(Console.ReadLine()) Console.Write("Enter second value: ") second = Double.Parse(Console.ReadLine()) Console.Write("Enter third value: ") third = Double.Parse(Console.ReadLine()) Console.Write("Enter fourth value: ") fourth = Double.Parse(Console.ReadLine()) Console.Write("Enter fifth value: ") fifth = Double.Parse(Console.ReadLine()) Console.Write("Enter sixth value: ") sixth = Double.Parse(Console.ReadLine()) Console.Write("Enter seventh value: ") seventh = Double.Parse(Console.ReadLine()) Console.Write("Enter eighth value: ") eighth = Double.Parse(Console.ReadLine()) Console.Write("Enter ninth value: ") ninth = Double.Parse(Console.ReadLine()) Console.Write("Enter tenth value: ") tenth = Double.Parse(Console.ReadLine()) average = (first + second + third + fourth + fifth + sixth + seventh + eighth + ninth + tenth) / 10 Console.WriteLine("Value of average: " & average) Console.WriteLine() Shell("cmd /c pause", AppWinStyle.NormalFocus, True) Else Dim radius_of_sphere, side_of_cube, volume_of_cube, volume_of_sphere As Double Dim input As String Console.WriteLine("To find the volume of a sphere input 1") Console.WriteLine("To find the volume of a cube input 2") input = Console.ReadLine If input = 1 Then Console.Write("Enter radius of sphere: ") radius_of_sphere = Double.Parse(Console.ReadLine()) volume_of_sphere = 4.0 * Math.PI * radius_of_sphere * radius_of_sphere * radius_of_sphere / 3 Console.WriteLine("Value of volume of sphere: " & volume_of_sphere) Console.WriteLine() Shell("cmd /c pause", AppWinStyle.NormalFocus, True) Else Console.Write("Enter value of one side of cube: ") side_of_cube = Double.Parse(Console.ReadLine()) volume_of_cube = side_of_cube * side_of_cube * side_of_cube Console.WriteLine("Value of volume of cube: " & volume_of_cube) Console.WriteLine() Shell("cmd /c pause", AppWinStyle.NormalFocus, True) End If End If End Sub End Module