using System.ComponentModel.DataAnnotations; internal class Program { public static double EnterMeasurement() // function for validating a number and ensuring data has been entered { double UserInput; // defines the UserInput integer do // defines the start of the do while loop { try // tries the code and let's it run { UserInput = double.Parse(Console.ReadLine()); // takes the users input and converts it into an integer using parse if (UserInput <= 0) // checks if user input is less than or equal to 0 { Console.WriteLine("Error, please enter a number greater than 0"); // outputs minimum user input to user } else { break; // breaks out of loop } } catch (FormatException) // performs the code in the event that a format exception has occurred, aka data that shouldn't be entered { Console.WriteLine("Error, unsuitable data entered. Please enter valid data"); // informs the user they have entered unsuitable data } } while (true); // will continuously perform the do while loop until a break has been reached return UserInput; } public static double PackageVolume(double a, double b, double c) // creates a function that uses 3 variables { double Volume = 0; // sets volume to 0 Volume = a * b * c; // sets volume to a * b * c return Volume; // returns volume to call } private static void Main(string[] args) { double Length = 0; // initialises length to 0 double Width = 0; // initialises width to 0 double Height = 0; // initialises height to 0 Console.WriteLine("Please enter the length"); // asks for length Length = Math.Round(EnterMeasurement(), 2); // sets length to entermeasurement method and rounds it Console.WriteLine("Please enter the width"); Width = Math.Round(EnterMeasurement(), 2); // sets width to entermeasurement method and rounds it Console.WriteLine("Please enter the height"); Height = Math.Round(EnterMeasurement(), 2); // sets height to entermeasurement method and rounds it Console.WriteLine("The values you have entered are (Length, Width, Height) : " + Length + ", " + Width + ", " + Height + " rounded to 2 decimal places"); // outputs length width and height to user Console.WriteLine("The volume of the package is " + Math.Round(PackageVolume(Length, Width, Height), 2)); // outputs rounded package volume to user } }