Skip to content

Instantly share code, notes, and snippets.

@Nikola-Andreev
Created January 17, 2017 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikola-Andreev/71442cc84d08c21aea2f29c6a86c3f20 to your computer and use it in GitHub Desktop.
Save Nikola-Andreev/71442cc84d08c21aea2f29c6a86c3f20 to your computer and use it in GitHub Desktop.
Area of figures
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Praktice
{
class Program
{
static void Main(string[] args)
{
string word = (Console.ReadLine());
if (word == "square")
{
var a = double.Parse(Console.ReadLine());
var area = a * a;
Console.WriteLine(area);
}
if (word == "rectangle")
{
var x = double.Parse(Console.ReadLine());
var y = double.Parse(Console.ReadLine());
var area1 = x * y;
Console.WriteLine(area1);
}
if (word == "circle")
{
var r = double.Parse(Console.ReadLine());
Console.WriteLine("Area = " + Math.PI * r * r);
}
if (word == "triangle")
{
var a = double.Parse(Console.ReadLine());
var h = double.Parse(Console.ReadLine());
var area2 = a * h / 2;
Console.WriteLine(Math.Round(area2, 2));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment