hello guys,
write a program which calculates the volume of a cube or of a sfere. the user gives the side of the cube or the radius of the sfere
• the user gives the shape as string
• the shape will be sfere or cube
otherwise will print "wrong shape"
here is my code, i write something wrong... it doesn't show what i want
using System;
class Shape
{
string shape;
string sfere= null, cube= null;
public string GetShape()
{
do{
Console.Write("Give the shape: ");
shape= Console.ReadLine();
if (shape== sfere|| shape== cube)
{
Console.WriteLine("Wrong shape");
}
} while (shape== sfere|| shape== cube);
return shape;
}
public void calculation (out double Volume)
{
double radius, side;
const double p = 3.14;
GetShape();
if (shape== sfere)
{
Console.Write("Give the radius of the sfere");
radius= Double.Parse(Console.ReadLine());
Volume= (4 / 3) * p * (Math.Pow(radius, 3));
}
else
{
Console.Write("Give the side of the cube");
side= Double.Parse(Console.ReadLine());
Volume= (Math.Pow(side, 3));
}
}
}
class Program
{
static void Main()
{
Shape sh1 = new Shape();
blah blah
Console.ReadKey();
}
}