using System.Collections.Generic;
using System.Collections;
interface IVolumeCalculator
public class Sphere : IVolumeCalculator,IInputReader
Console.WriteLine("Enter radius:");
string input = Console.ReadLine();
radius = double.Parse(input);
public void computeVolume()
double vol =(4 * Math.PI * radius * radius * radius)/3;
Console.WriteLine("Volume of the sphere:"+vol);
public class Pyramid : IVolumeCalculator,IInputReader
Console.WriteLine("Enter radius and height:");
string input1 = Console.ReadLine();
string input2 = Console.ReadLine();
radius =double.Parse(input1);
height =double.Parse(input2);
public void computeVolume()
double vol = (radius * height)/3;
Console.WriteLine("Volume of the Pyramid:"+vol);
public class Cone : IVolumeCalculator,IInputReader
Console.WriteLine("Enter radius and height:");
string input1 = Console.ReadLine();
string input2 = Console.ReadLine();
radius = double.Parse(input1);
height =double.Parse(input2);
public void computeVolume()
double vol = (Math.PI * radius * radius * height)/3;
Console.WriteLine("Volume of the cone:"+vol);
public class Cuboid : IVolumeCalculator,IInputReader
double length,breadth,height;
Console.WriteLine("Enter length, breadth and height:");
string input1 = Console.ReadLine();
string input2 = Console.ReadLine();
string input3 = Console.ReadLine();
length = double.Parse(input1);
breadth =double.Parse(input2);
height =double.Parse(input3);
public void computeVolume()
double vol = length * breadth * height;
Console.WriteLine("Volume of the cuboid:"+vol);
public class AreaCalculatorApplication
public static void Main()
Console.WriteLine("Enter\n1.Sphere\n2.Pyramid\n3.Cone\n4.Cuboid");
string input = Console.ReadLine();
Dictionary<string, Object> myDict = new Dictionary<string, Object>();
myDict.Add("1", new Sphere());
myDict.Add("2", new Pyramid());
myDict.Add("3", new Cone());
myDict.Add("4", new Cuboid());
while(char.IsDigit(input[0])== false || float.Parse(input)>4)
Console.WriteLine("Enter a valid choice");
input=Console.ReadLine();
List<QuestionAnswer> qaList = new List<QuestionAnswer>(valuesDict.Keys.Count);
int choice =int.Parse(input);
foreach (KeyValuePair<string, Object> result in myDict)
qaList.add(new QuestionAnswer {Question = item.Key, Answer = item.Value});
Sphere sphere = new Sphere();
Sphere sphere = new Sphere();
Pyramid pyramid = new Pyramid();
Cuboid cuboid = new Cuboid();
Console.WriteLine("Invalid Choice");