C# Area of Circle | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C# Area of Circle

I am still a beginner and learned a few basics on variables, so I have managed to get the 1st part of the problem but cant find a way to solve all of them at once. Your help will be highly appreciated. xx

14th Jul 2021, 6:56 PM
Lawrance Tosa
Lawrance Tosa - avatar
8 Answers
+ 5
Please save your attempt on SL Playground and link here.
14th Jul 2021, 6:59 PM
JaScript
JaScript - avatar
+ 2
Your code should work for each input. You have to read the radius and calculate with it. Plesse try that.
14th Jul 2021, 7:21 PM
JaScript
JaScript - avatar
+ 2
Lawrance Tosa You need to know what this line do. Convert.ToDouble(t); You didn't take input. Don't write Hard Code logic.
14th Jul 2021, 7:43 PM
A͢J
A͢J - avatar
0
https://code.sololearn.com/c8a22A11a199/#cs hope you understand what I did there
14th Jul 2021, 7:11 PM
Lawrance Tosa
Lawrance Tosa - avatar
0
I declared variable t and gave it a value of pi * radius, isn't that the input?
14th Jul 2021, 8:26 PM
Lawrance Tosa
Lawrance Tosa - avatar
0
I used the Convert.ToDouble because the instructions said convert the inputted value to double
14th Jul 2021, 8:28 PM
Lawrance Tosa
Lawrance Tosa - avatar
- 1
Lawrance Tosa review your previous lesson(s) wich should have teached how to get input from user, as a double value in 'radius' variable... next, use it to compute area by doing PI*radius*radius (squared radius), but avoid using PI as self defined constant number with only 2 digits precision after dot, but rather use the builtin constant available in Math module ;)
14th Jul 2021, 11:50 PM
visph
visph - avatar
- 1
Is it also possible to write the code with ()² or ^2? I already know the writing goes like ... (radius * radius) but i am wondering if there is a more easy way of coding it ... Thx ;)
31st Aug 2021, 8:31 AM
FromAlex TotheAnder
FromAlex TotheAnder - avatar