Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp27
- {
- class Program
- {
- static void Main(string[] args)
- {
- float[] xValues = { -2.37f, -0.49f,7.51f};
- foreach (float value in xValues)
- Console.WriteLine($"x:{value} - y:{CalculationFunction(value)}");
- }
- private static float CalculationFunction(float x)
- {
- float a = 2.1f;
- float b = 6.7f;
- float y;
- if (x < -2)
- y = MathF.Pow(x,3) + 2 * a;
- else if (x < 5 && x >= -2)
- y = MathF.Log(MathF.Abs(MathF.Cos(b*x)),MathF.E);
- else
- y = MathF.Pow(x,2) * MathF.Pow(MathF.E,x);
- return y;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment