Is there a task, that: "Given the sin x function's values in 0, 0,2 0,4 0.5 points. With Langrange's interpolation polynomial of sin 0,15 which can be accurately calculated?
I have an algorithm:

class Interpolacio
{
//Langrange's interpolation
public static void Lagrange()
{
Console.Write("Number of measurement locations(n)=");
int n = int.Parse(Console.ReadLine());
double[] x = new double[n];
double[] y = new double[n];

Console.WriteLine("x values in ascending order:");
for (int i = 0; i < n; i++)
{
Console.Write("x{0}=", i + 1);
x = double.Parse(Console.ReadLine());
}
Console.WriteLine("y values:");
for (int i = 0; i < n; i++)
{
Console.Write("y{0}=", i + 1);
y = double.Parse(Console.ReadLine());
}

Console.Write("
the place where the value of the function you want=");
double xx = double.Parse(Console.ReadLine());

double s = 0;
double r = 1;

for (int i = 0; i < n; i++)
{
r = 1;
for (int j = 0; j < n; j++)

{
if (i != j)
{
r *= xx - x[j];
r /= (double)(x - x[j]);
}
}
r *= y;
s += r;
}

Console.Write("The function value={0}", s);
Console.ReadKey();
}


I need this an college test!
How to rewrite that algorithm, that do this?

Thank you for everything