1 Off: calculated perimeter and area of a circle

mission details

This related tasks: circle radius from the keyboard r, and the area of circular perimeter, the formula are: perimeter =2*π*r, area = π*r*r.

Note: the radius required rto be input from the keyboard. πValue takes a constant value 3.14.

Task Analysis

This task is determined according to the area of ​​the circumference of a circle and radius of the circle. Perimeter and area formula is simple, but requires computer processing. Process the data necessary to define the variables, this task needs to be defined radius, perimeter and area of ​​three variables. Computer must define the type of variable, this type of task three variables are floating point numbers.

Programming requirements

The tips on the right supplemental code editor, and outputs the calculated area and circumference of a circle.

Please calculate the decimal type.

test introduction

Platform code you write will be tested:

Test input:4

Expected output:

周长=25.12

面积=50.24

Test input:12

Expected output:

周长=75.36

面积=452.16


Start your mission, I wish you success!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ch201
{
    class Program
    {
        static void Main(string[] args)
        {
			/******begin*******/
			const decimal PI = 3.14M;
            decimal r, area, perimeter;
            r = Convert.ToDecimal(Console.ReadLine());
            area = PI * r * r;
            perimeter = 2 * PI * r;
            Console.WriteLine("周长={0}", perimeter);
            Console.WriteLine("面积={0}", area);
			
			
			
			/*******end********/

        }
    }
}

  

Guess you like

Origin www.cnblogs.com/mjn1/p/12482185.html