//To wklejasz w funkcji main
Console.WriteLine("Please enter radius: ");
double a = double.Parse(Console.ReadLine());
Console.WriteLine("Please enter generatix: ");
double b = double.Parse(Console.ReadLine());
//zadanie 2
try
{
Console.WriteLine("Cone field: " + PolePowCalkStozka(a, b));
}
catch (DivideByZeroException e)
{
Console.WriteLine("Values can't be 0");
}
catch (InvalidOperationException e)
{
Console.WriteLine("Values must be >0");
}
catch (DataMisalignedException)
{
Console.WriteLine("You entered incorrect parameters");
}
// a to poza funkcją main
public static double PolePowCalkStozka(double promien, double tworzaca)
{
double height = Math.Sqrt(Math.Pow(tworzaca, 2) - Math.Pow(promien, 2));
double field;
if (promien < 0 || tworzaca < 0)
{
throw new System.InvalidOperationException();
}
else if(promien+height<tworzaca || promien+tworzaca<height || height + tworzaca < promien)
{
throw new System.DataMisalignedException();
}
else if(promien==0 || tworzaca == 0)
{
throw new System.DivideByZeroException();
}
else
{
field = (Math.PI * promien) * (promien + tworzaca);
return field;
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}