Answer the question
In order to leave comments, you need to log in
How to shorten to 4 decimal places, for cos2 and sin2?
class SinCos
{
public readonly double Sin2;
public readonly double Cos2;
public SinCos(double x)
{
Sin2 = square(Math.Sin(x));
Cos2 = square(Math.Cos(x));
Math.Round(Sin2, 4);
}
private double square(double x)
{
return x * x;
}
public override string ToString()
{
return "Sin2a = " + Sin2 + " ; Cos2a = " + Cos2;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Table of values from –pi to pi in increments of pi/4.");
Console.WriteLine("\n");
double begin = -Math.PI;
double end = Math.PI;
double step = Math.PI / 4.0;
end += step / 2.0;
for (double i = begin; i < end; i += step)
{
Console.WriteLine("i = {0:f4}", i);
Console.WriteLine(new SinCos(i));
Console.WriteLine("");
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question