+ 3

Finishing code project on area of a circle

I simply can't create the output. As in, I've created an output but can't figure out how to display it. Have I missed a tutorial? This is the code: 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; if (args.Length == 0) { return; } radius = Convert.ToInt32(args[0]); double circleArea = pi * radius * radius; // Console.WriteLine(circleArea); // MessageBox.Show(circleArea); // Debug.WriteLine(circleArea); } } }

4th Mar 2022, 5:12 PM
Jannick Breunis
Jannick Breunis - avatar
5 odpowiedzi
+ 2
Console.WriteLine(circleArea) ; But in Sololearn, it not work on input by main argument passing.. .. You should take input by radius = double.Parse( Console.ReadLine() ) ; edit: Jannick Breunis remove if block , as it cause return.
4th Mar 2022, 5:15 PM
Jayakrishna 🇮🇳
+ 4
Your code is here... 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 = Convert.ToDouble(Console.ReadLine()); Console.WriteLine(pi*radius*radius); }}}
4th Mar 2022, 5:54 PM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 2
Yes that's it! Question answered. Thanks both!
4th Mar 2022, 5:56 PM
Jannick Breunis
Jannick Breunis - avatar
+ 1
Ah ofcourse.. Changed the int-conversion (facepalm) too: 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; if (args.Length == 0) { return; } radius = double.Parse(Console.ReadLine()); double circleArea = pi * radius * radius; Console.WriteLine(circleArea); // MessageBox.Show(circleArea); // Debug.WriteLine(circleArea); } } } But still getting "Your Output No Output"
4th Mar 2022, 5:36 PM
Jannick Breunis
Jannick Breunis - avatar
0
Sololearn does not have args. if args length = 0 return. So the code exits in the first if statement. For the code coach problem the input values are filled in automatically. Just Console.Readine and string to double conversion, should be Ok. Tนktนk💕 Your code is the correct code.
4th Mar 2022, 5:57 PM
sneeze
sneeze - avatar