Answer to Question #284778 in C# for tes

Question #284778

use method to create a program that will display the area of circle based on the radius inputted by the user.It should contain the following method:input_radius,comp_area and display_result.You may use the formula: A=r², where r=3.1416

1
Expert's answer
2022-01-05T08:13:46-0500
using System;
namespace Area_of_a_circle
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            Console.Write("Enter a radius: ");
            double radius = double.Parse(Console.ReadLine());
            Input_Radius(radius);
            Comp_Area(Input_Radius(radius));
            Display_Result(Comp_Area(Input_Radius(radius)));
            Console.ReadLine();
        }
        static double Input_Radius(double radius)  // Method Input_Radius
        {
            return radius;
        }

        static double Comp_Area(double r)  // Method Comp_Area
        {
            double p = 3.14;  // const pi
            double s = p * Math.Pow(r, 2); // area
            return s;
        }

        static void Display_Result(double s)  // Method Display_Result
        {
            Console.WriteLine($"Area of a circle based on radius = {s}");
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS