Sunday, March 16, 2014

If_Else_Structure_: (Wk-4), Jan 27-31, 2014




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace If_Else_Structure
{
    class Program
    {
        static void Main(string[] args)
        {
            //Given x, y axis with 4 quandrants (I, II, III, IV)
            //Request two values x and y,
            //then determine the location of the point.
            //A point may be in either of the quadrants as well as
            //on the x axis or y axis


            repeat:
            Console.Write("Enter the value of x: ");
            double x = double.Parse(Console.ReadLine());

            Console.Write("Enter the value of y: ");
            double y = double.Parse(Console.ReadLine());

            if (x > 0 && y > 0)
            {
                Console.WriteLine("The location of your point is in quadrant I");
            }
            else if (x < 0 && y > 0)
            {
                Console.WriteLine("The location of your point is in quadrant II");
            }
            else if (x < 0 && y < 0)
            {
                Console.WriteLine("The location of your point is in quadrant III");
            }
            else
            {
                Console.WriteLine("The location of your point is in quadrant IV");
            }
            Console.ReadLine();
            Console.Clear();
            goto repeat;
        }
    }
}

No comments:

Post a Comment