Write a console application that uses at least five different method of math class. Provide a meaningful identifier of the variables are constant. Name the namespace as mathApp and it's class as mathProgram.
using System;
namespace mathApp
{
class mathProgram
{
public delegate double PerformCalculation(double _input);
static PerformCalculation _pc;
static void Main(string[] args)
{
string pick = Console.ReadLine();
switch (pick)
{
case "Abs":
_pc = Math.Abs;
break;
case "Sin":
_pc = Math.Sin;
break;
case "Cos":
_pc = Math.Cos;
break;
case "Log":
_pc = Math.Log;
break;
case "L10":
_pc = Math.Log10;
break;
default:
return;
}
double _input = Convert.ToDouble(Console.ReadLine());
double output = _pc(_input);
Console.WriteLine(output);
Console.ReadLine();
}
}
}
Comments
Leave a comment