Thursday, March 24, 2016

URI 1002 SOLUTION in C, C++ and Java language-Area of a circle

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".


See a video to solve URI 1002 in C language



Input SamplesOutput Samples
2.00A=12.5664
100.64A=31819.3103
150.00A=70685.7750


URI Solution - 1002 -->Solution in C language : 


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

Run this code URI 1002 In live:



URI Solution - 1002 --> Solution in C++ language 

#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;

}

URI Solution - 1002 --> Solution in Java language 

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);
   }
}


This is the simple solution of area of a circle . It's detail is described in the problem. So I think no need to describe it. Since if you face any problem to solve this, please comment below..

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.