Clock question

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Collections;

 

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine(GetAngleInDegrees(7, 00));

        }

        public static double GetAngleInDegrees(double hours, double minutes)

        {

            if (hours > 12)

            {

                hours = hours – 12;

            }

            double hourHandDisplacement = (hours * 5 * 6) + (minutes * 6 * 1/12);

            double minuteHandDisplacement = (minutes * 6);

            double angle = Math.Abs(hourHandDisplacement – minuteHandDisplacement);

            if (angle > 180)

            {

                return (360.0 – angle);

            }

            else

            {

                return angle;

            }

        }

    }

}

Advertisements
This entry was posted in Information Technology. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s