double r; double area, circum; StreamReader Str = new StreamReader("My_File.txt"); //Path of file while (Str.Peek() > -1) { r = double.Parse(Str.ReadLine()); area = Math.Round( (r*r*22)/7,4);
circum = Math.Round((2 * 22 * r) / 7,4);
Console.WriteLine("Redius is {0} and Area is={1} and Circum is={2}", r, area, circum);
} Console.ReadLine();
this is example for console application .
Note: your file must be in the debug folder of your console application........
+1
Sai BagewadiRank #8,712 · 217 reputationPosted May 18, 2015, 4:58 PM EDT
+1
Hi,
Make sure you edit code to put the local path of circle.txt file.
Console.WriteLine("For the circle radius of {0}, Here are the computed values Area:{1}, Circumference:{2}", circleRad, FindArea(circleRad), FindCircumference(circleRad));
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted May 18, 2015, 5:00 PM EDT
double area, circum;
StreamReader Str = new StreamReader("My_File.txt"); //Path of file
while (Str.Peek() > -1)
{
r = double.Parse(Str.ReadLine());
area = Math.Round( (r*r*22)/7,4);
circum = Math.Round((2 * 22 * r) / 7,4);
Console.WriteLine("Redius is {0} and Area is={1} and Circum is={2}", r, area, circum);
}
Console.ReadLine();
Sai BagewadiRank #8,712 · 217 reputationPosted May 18, 2015, 4:58 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts