Program to Get Angle Bewteen Hour and Minute

Program to get angle between hour and minute using C#.
 
class Program
{
    static void Main(string[] args)
    {
        myprog ob = new myprog();
        ob.hour_min();
        Console.ReadLine();
    }
}

public void hour_min()
{
    Console.Write("Enter hours (0 to 11) : ");
    int hours = int.Parse(Console.ReadLine());
    Console.Write("Enter minutes (0 to 59) : ");
    int mins = int.Parse(Console.ReadLine());
    double hDegrees = (hours * 30) + (mins * 30.0 / 60);
    double mDegrees = mins * 6;
    double diff = Math.Abs(hDegrees - mDegrees);
    Console.WriteLine("The angle between the hands is {0} degrees", diff);
    Console.Write("Do another y/n : ");
    string yn = Console.ReadLine();

    if (yn == "n") return;
    Console.WriteLine();

    Console.ReadLine();

}
Ebook Download
View all
Learn
View all