+ 4

Can anyone tell me whats wrong in my code to find the area of the circle in C#(End of Module project)

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; double area; //your code goes here Console.Writeline ("Enter the radius of the circle"); radius = Convert.Todouble(Console.Readline()); area = pi * radius * radius; Console .Writeline("Area of the circle is {0} of {1}",area, radius ); } } }

7th Mar 2021, 4:16 AM
AJP
AJP - avatar
6 odpowiedzi
+ 3
Try this 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) { double pi = 3.14; double diameter =Convert.ToDouble(Console.ReadLine()); Console.WriteLine(pi*diameter*diameter); } } }
7th Mar 2021, 4:34 AM
K.S.S. Karunarathne
K.S.S. Karunarathne - avatar
+ 6
But it said there is no such function named console.writeline
7th Mar 2021, 4:29 AM
AJP
AJP - avatar
+ 5
Thanks a lot.
7th Mar 2021, 4:38 AM
AJP
AJP - avatar
+ 4
Now it is saying that convert does not contain to double function
7th Mar 2021, 4:33 AM
AJP
AJP - avatar
+ 2
Console.WriteLine(); Is this what you are saying.
7th Mar 2021, 4:30 AM
K.S.S. Karunarathne
K.S.S. Karunarathne - avatar
+ 1
Alice Petey Just return the area of the circle don't put anything else. And delete the "Enter the radius of the circle part". Then it'll be okay If you don't understand please check out this code. https://code.sololearn.com/cyUPm2my7GBR/?ref=app
7th Mar 2021, 4:28 AM
K.S.S. Karunarathne
K.S.S. Karunarathne - avatar