Wednesday, 27 July 2011

Condition to checking the time range

         Actually half a day I am seeking a right solution to check the time range for the hall management project.  For example the hall is booked for a meeting from 9.00 am to 11.00 am on a particular day.  If any other user try to book the hall at a time which include this time range.
        
         Here these timing are possible to crash  1. exact 9am to 11am
                                                                          2. 8.30am to 9.30 am
                                                                          3. 9.30 am to 10 am
                                                                          4. 8am to 12 pm

         We must check all of these conditions before book the hall 

         Here the solved condition in as C# program  consider extStart as existing start time extEnd as existing End time (i.e) the previous entries


sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace conditioncheck
{
    class Program
    {
        static void Main(string[] args)
        {

            float extStart = 9, extEnd = 11;
            Console.WriteLine("The existing strat time is {0} \n End time is {1} \n", extStart, extEnd);
            Console.WriteLine("Enter the start time and end time ");
            float givenStart = float.Parse(Console.ReadLine());
            float givenEnd = float.Parse(Console.ReadLine());

            Console.WriteLine("The given strat time is {0} \n End time is {1} ", givenStart, givenEnd);
           

            if (((givenStart>=extStart)&&(givenStart<extEnd))||((givenStart<=extStart)&&(givenEnd>extStart)))
                {
                Console.WriteLine("Meeting Crashes ");
                }
                else
                {
                    Console.WriteLine("Meeting not crashes ");
                }
            Console.Read();


        }
    }
    }

No comments:

Post a Comment