WRITTEN IN C# - VISUAL STUDIO WRITTEN IN C# - VISUAL STUDIO 3. (Diameter, Circum
ID: 3727229 • Letter: W
Question
WRITTEN IN C# - VISUAL STUDIO
WRITTEN IN C# - VISUAL STUDIO
3. (Diameter, Circumference and Area of a Circle) Write a C# program that firstly repeats the following operations for five times: (20 points) ask the user to input the radius of a circle as an integer . if the user's input is less than zero, remind the user. otherwise, calculate and display the circle's diameter, circumference and area. Then, output a message to inform the user that he/she has input for five times. When working on this question, you should use the double value 3.14159 to represent TT, and the following formulas: diameter = 2r circumference = 2mr area = TTr2 Hint: use do...whileExplanation / Answer
using System;
class Circle
{
public static void Main()
{
double r;
double diameter;
double area;
double circumference;
for(int i=0;i<5;i++){
Console.WriteLine("Enter Radius:");
r=Convert.ToDouble(Console.ReadLine());
if(r<=0){
Console.WriteLine("Enter Radius greater than zero:");
r=Convert.ToDouble(Console.ReadLine());
}
diameter=(2*r);
area=(3.14*r*r);
circumference=(2*3.14*r)
Console.WriteLine("diameter: ",diameter);
Console.WriteLine("circumference:",circumference);
Console.WriteLine("area:",area);
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.