Tuesday 30 April 2013

John is a software developer, who works for Mega Technologies. He is currently under the project of geometric calculations. The program that John has to develop should: Calculate the area of circle. Calculate the volume of the cube.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication7

{



class geo

{

int a, r,area,volume;

public void ca()

{

Console.WriteLine("Enter the radius of circle:");

r = Convert.ToInt32(Console.ReadLine());

area = 22/7 * r * r;

Console.WriteLine("the area of circle:" + area);

}

public void cv()

{

Console.WriteLine("Enter the side of cone:");

a = Convert.ToInt32(Console.ReadLine());

volume = a*a*a;

Console.WriteLine("the volume of cone:" + volume);

}

}

class Program

{

static void Main(string[] args)

{

int s;

Console.WriteLine("Enter 1 for area of circle and 2 for Volume of cone:");

s=Convert.ToInt32(Console.ReadLine());

geo g = new geo();

switch (s)

{

case 1:

g.ca();

break;

case 2:

g.cv();

break;

default:

Console.WriteLine("invalid selection");

break;

}

Console.ReadLine();

}

}

}


No comments:

Post a Comment