 Can some one please help me to solve this one? | Sololearn: Learn to code for FREE!

+2

We are going to write a program that will calculate the area of ​​a circle. The area enclosed by a circle of radius r is πr², where π (pi) is the constant ratio of the circumference of any circle to its diameter, and r is the radius. The given program declares a constant pi variable with a value of 3.14. Complete the program to take the radius as input, then calculate and output the area of the circle. Sample Input 5 Sample Output 78.5

+1

+4

Tim Tam follow these steps: 1. Take input into the variable radius, using Console.ReadLine() 2. Create a variable, (suppose area for example.) 3. Calculate area of circle by the given formula: area = pi * radius * radius; 5. Print the area using : Console.WriteLine(area); And still if you're unable to solve the challenge, kindly revisit on previous chapters. Happy Coding :)

+3

Tim Tam here you go.. https://code.sololearn.com/cVVXV2H2Jg8A/?ref=app

+2

+1

https://code.sololearn.com/cvHtMNlx0Kkt double r = Convert.ToDouble(Console.ReadLine()); double a = Math.PI * Math.Pow(r, 2.0); Console.WriteLine(Math.Round(a, 1)); // Keep learning & happy coding :D

+1

Thank you so much guys😍😍😍

+1

Hi SoloProg, Because the method you did I haven't learned so I tried to combine you and Rupali together but still something wrong, Can someone help me to fix it using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { const double pi = 3.14; double radius; radius = 5; Convert.ToDouble(Console.ReadLine(area)); area = pi*radius*radius; Console.WriteLine(area); //your code goes here } } }

+1

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { const double pi = 3.14; double radius = Convert.ToDouble(Console.ReadLine()); // For all test cases double area = pi*radius*radius; Console.WriteLine(area); } } }

+1

Because we have a decimal (pi) so the result must be decimal.

0

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { const double pi = 3.14; double radius; //your code goes here } } }

0

Yay I got it guys Thank you so much, Another thing is testcase number is done but in the test case number 2 still show the results of the test case number input 5 and out put 78.5, Just want to ask how to separate 2 test case or I mean I can have another input for radius like radius = 6.4 Hope you guy understand what I am trying to say😅

0

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { const double pi = 3.14; double radius = 5; Convert.ToDouble(Console.ReadLine()); double area = pi*radius*radius; Console.WriteLine(area); //your code goes here } } } { static void Main(string[] args) { const double pi = 3.14; double radius = 6.4; Convert.ToDouble(Console.ReadLine()); double area = pi*radius*radius; Console.WriteLine(area); //your code goes here } } }

0

the Radius is not meant to be named twice and because you're radius is a while number it's not a double its a whole number meaning you should equal it to an int if you want to name your area variable a double do cause the answer will have a , after it meaning answer could be 2.2 example only.not answer hope it helps