Answer to Question #187124 in C# for angelo r reyes

Question #187124

Create a program to compute the volume of a sphere. Use the formula: V= (4/3)*πr 3 where π is equal to 3.1416 approximately. The variable r is the radius. Display the volume of a sphere.


1
Expert's answer
2021-04-29T06:53:31-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace C_SHARP
{
    class Program
    {


        static double getRadius()
        {
            Console.Write("Enter a radius of sphere: ");
            return double.Parse(Console.ReadLine());
        }
        static void Main(string[] args)
        {


            double radius = getRadius();
            double volume = (4.0 / 3.0) * Math.PI * Math.Pow(radius, 3.0);
            Console.WriteLine("The volume of a sphere is {0}",volume.ToString("N2"));
            Console.ReadLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS