Saturday, March 1, 2014

Boolean03: (Wk-2), Jan 16, 2014

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

namespace Boolean03
{
    class Program
    {
        static void Main(string[] args)
        {
            //Request three integers x, y, z from user, then check the following questions;
            //1. Is x greater than z?
            //2. Is y less than or equal to x?
            //3. Is z not equal to y?
            //4. Is y equal the sum of x and z?
            //5. Is z greater than the sum of x and y?
            //6. Is z more than twice y?
            //7. Is y less than half x?
            //8. Is the sum of x, y and z more than 200?
            //9. Is the average value of x, y and z less than 50?
            //10. Is z more than (2* x - y)?


            int x, y, z;
            Console.Write("Enter the value of x: ");
            x = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter the value of y: ");
            y = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter the value of z: ");
            z = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine();

            bool b1, b2, b3, b4, b5, b6, b7, b8, b9, b10;

            b1 = (x > z);
            b2 = (y <= x);
            b3 = (z != y);
            b4 = (y == (x + z));
            b5 = (z > x + y);
            b6 = (z > y + y);
            b7 = (y < (x / 2));
            b8 = ((x + y + z) > 200);
            b9 = ((x + y + z) / 3 < 50);
            b10 = (z > (2 * x - y));

            Console.WriteLine("Is x greater than z? : {0}", b1);
            Console.WriteLine("Is y less than or equal to x? : {0}", b2);
            Console.WriteLine("Is z not equal to y?: {0}", b3);
            Console.WriteLine("Is y equal the sum of x and z?: {0}", b4);
            Console.WriteLine("Is z greater than the sum of x and y?: {0}", b5);
            Console.WriteLine("Is z more than twice y?: {0}", b6);
            Console.WriteLine("Is y less than half x?: {0}", b7);
            Console.WriteLine("Is the sum of x, y and z more than 200?: {0}", b8);
            Console.WriteLine("Is the average value of x, y and z less than 50?: {0}", b9);
            Console.WriteLine("Is z more than (2* x - y)?: {0}", b10);

            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment