Exemplo n.º 1
0
        public void Circle()
        //Input: radius = 4  Output: area = 50.27  circumference = 25.13
        //This method gives the area and circumference of a circle when the radius is givin.
        {
            //the radius is converted to a double data type
            Console.Clear();
            DisplayMenu menu  = new DisplayMenu();
            string      input = "";

            Console.Write("Enter the radius of the circle in inches: ");
            input = Console.ReadLine();
            double radius = CheckNumber(input);

            if (radius > 0)
            {
                //the variable PI is declare here so I don't have to keep typing out Math.PI
                double pi            = Math.PI;
                double area          = pi * (radius * radius);
                double circumference = 2 * pi * radius;

                //Gives the result as a double with a max of two decimals
                Console.WriteLine($"Your area is: {area:0.00}in");
                Console.WriteLine($"Your circumference is: {circumference:0.00}in");
                Console.Read();
            }
            else if (radius == 0)
            {
                Console.WriteLine("Value must be greater than 0");
                Console.ReadLine();
            }
            else
            {
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            DisplayMenu menu = new DisplayMenu();

            menu.Menu1();
        }