Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace GeometryCalculator
- {
- class Program
- {
- static void Main(string[] args)
- {
- string figure = Console.ReadLine();
- if (figure == "square" || figure == "circle")
- {
- GetArea(figure, double.Parse(Console.ReadLine()));
- }
- else
- {
- GetArea(figure, double.Parse(Console.ReadLine()), double.Parse(Console.ReadLine()));
- }
- }
- public static void GetArea(string figure, double num1, double num2 = 42) // 42 = The answer to life the universe and everything
- {
- switch (figure.ToLower())
- {
- case "triangle":
- Console.WriteLine("{0:0.00}", num1 * num2 / 2);
- break;
- case "square":
- Console.WriteLine("{0:0.00}", num1 * num1);
- break;
- case "rectangle":
- Console.WriteLine("{0:0.00}", num1 * num2);
- break;
- case "circle":
- Console.WriteLine("{0:0.00}", Math.PI * (num1 * num1));
- break;
- default:
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement