Algorithm


URI Problem 1002 Online Linkhttps://www.urionlinejudge.com.br/judge/en/problems/view/1002

 

Algorithm - 

We know Pi = 3.14159

  1. Take input the radius - R
  2. Area = Pi * R2
  3. Print as float Upto 4 decimal
  4. Must use return with a new line \n

Code Examples

#1 Code Example with C Programming

Code - C Programming

#include<stdio.h>
int main()
{
    double R, A;
    scanf("%lf", &R);
    A = 3.14159 * R * R;
    printf("A=%.4lf\n", A);
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2.00

Output

x
+
cmd
A=12.5664

#2 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include <iomanip>
using namespace std;

int main(){
    double R,A;
    cin >> R;
    A = 3.14159 * R * R;
    cout << "A=" << fixed << setprecision(4) << A << endl;
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
100.64

Output

x
+
cmd
A=31819.3103

#3 Code Example with Java Programming

Code - Java Programming

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        double R,A;
        Scanner sc = new Scanner(System.in);
        R = sc.nextDouble();
        A = 3.14159 * R * R;
        System.out.printf("A=%.4f\n",  A);
   }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
150.00

Output

x
+
cmd
A=70685.7750

#4 Code Example with Python Programming

Code - Python Programming

R = float(input())

Area =  3.14159 * R * R

print("A=%0.4f" %Area)
Copy The Code & Try With Live Editor

Input

x
+
cmd
4

Output

x
+
cmd
A=50.2654

#5 C# Example Solution URI 1002

Code - C Programming

using System;
class URI {

    static void Main(string[] args) {
        double radio, area;
        radio = Convert.ToDouble(Console.ReadLine());
        area = 3.14159 * (radio * radio);
        Console.WriteLine("A="+area.ToString("0.0000"));
        Console.ReadKey();
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5

Output

x
+
cmd
A=78.5397
Advertisements

Demonstration


URI Online Judge | 1002

Area of a Circle

Adapted by Neilor Tonin, URI  Brazil

Timelimit: 1

The formula to calculate the area of a circumference is defined as A = π . R2. Considering to this problem that π = 3.14159:

Calculate the area using the formula given in the problem description.

Input

The input contains a value of floating point (double precision), that is the variable R.

Output

Present the message "A=" followed by the value of the variable, as in the example bellow, with four places after the decimal point. Use all double precision variables. Like all the problems, don't forget to print the end of line after the result, otherwise you will receive "Presentation Error".

 
Input Samples Output Samples

2.00

A=12.5664

100.64

A=31819.3103

150.00

A=70685.7750

Previous
#1001 - Beecrowd Online Judge Solution 1001 with C, C++, Java, Python, PHP, C#, JavaScript
Next
#1003 Beecrowd Online Judge Solution 1003 Simple Sum | Solution in C, C++, Java, Python and C#