5.1. [15 marks] Write a method with the following details:
5.2. [10 marks] Using the method below, write the code statements to call this method ten times with angle values of 0.500, 0.501, 0.502, 0.503, ... 0.509 and printout the values for the angle, resulting sine and cosine in a tabular format. Use a “for” looping structure.
using System;
namespace SineCosine
{
class Program
{
public static void SineCosine(double angle, out double sin, out double cos)
{
sin = Math.Sin(angle);
cos = Math.Cos(angle);
}
public static void Main(string[] args)
{
double angle, sine, cosine;
Console.WriteLine("{0}\t\t{1}\t\t\t{2}","Angle", "Sine", "Cosine");
for(int i=0; i<10; i++)
{
angle = 0.500 + Convert.ToDouble(i)/1000;
SineCosine(angle, out sine, out cosine);
Console.WriteLine("{0:0.000}\t{1}\t{2}", angle, sine, cosine);
}
Console.Write("\nPress any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Comments
Leave a comment