Sunday, March 2, 2014

Conditional_Operators_Ex02: (Wk-3), Jan 22, 2014

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

namespace Conditional_Operators_Ex02
{
    class Program
    {
        static void Main(string[] args)
        {
            //Write an if statement whose condition is true
            //when x is equal to 5, and
            //      y is greater or equal to 3, and

            //      z is less than 10

            startover:
            Console.Write("Enter an x value: ");
            int x = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter a y value: ");
            int y = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter a z value: ");
            int z = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Checking if x == 5 and y >= 3 and z < 10");

            if (x==5 && y >= 3 && z < 10)
            {
                Console.WriteLine("\nAll condition have been met");
            }
            else
            {
                Console.WriteLine("Either one of them was not true");
            }
            Console.WriteLine("\n\nHit a key to continue");
            Console.ReadLine();
            Console.Clear();
            goto startover;
        }
    }
}

No comments:

Post a Comment