Beispiel #1
0
        static void Main(string[] args)
        {
            bool flag = true;

            while (flag)
            {
                Console.WriteLine("Functional Programs");
                Console.WriteLine("1.Two Dimensional Array");
                Console.WriteLine("2.Triplets Add To Zero");
                Console.WriteLine("3.Distance");
                Console.WriteLine("4.Quadratic");
                Console.WriteLine("5.WindChill");
                Console.WriteLine("6.Exit");
                Console.Write("\nEnter your choice: ");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    TwoDArray.input();
                    break;

                case 2:
                    TripletsAddZero.ArrayInput();
                    break;

                case 3:
                    Distance.Input();
                    break;

                case 4:
                    QuadraticEquation.Input();
                    break;

                case 5:
                    WindChill.Input();
                    break;

                case 6:
                    flag = false;
                    break;

                default:
                    Console.WriteLine("\nEnter valid choice\n");
                    break;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// define the entry point of the application
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                int    choose;
                string yes;
                do
                {
                    Console.WriteLine(" 1.StringReplace \n 2.FlipCoin \n 3.LeapYear \n 4.PowerOfTwo \n 5.HarmonicNumber \n 6.PrimeFactor ");
                    Console.WriteLine(" 7.Gambler \n 8.CouponNumber \n 9.2DArry \n 10.FindTriplets \n 11.FindThedistance \n 12.permutation ");
                    Console.WriteLine(" 13.StopWatch \n 14.TIC_TAC_TOE_GAME \n 15.QudraticEquation \n 16.WindChill");
                    Console.WriteLine("enter the your choose");
                    choose = Convert.ToInt32(Console.ReadLine());
                    switch (choose)
                    {
                    case 0:
                        Environment.Exit(0);
                        break;

                    case 1:
                        StringReplace.Replace();
                        break;

                    case 2:
                        FlipCoin.CoinFlip();
                        break;

                    case 3:
                        LeapYear.Yearleap();
                        break;

                    case 4:
                        PowerOfTwo.TwoToThePower();
                        break;

                    case 5:
                        HarmonicNumber.Harmonicnumber();
                        break;

                    case 6:
                        PrimeFactor.Primefactor();
                        break;

                    case 7:
                        GamblerProgram.Gambler();
                        break;

                    case 8:
                        CouponNumbers.Couponnumbers();
                        break;

                    case 9:
                        TwoDArray.TwodArray();
                        break;

                    case 10:
                        FindTriplets.Integernumber();
                        break;

                    case 11:
                        DistanceProgram.CalculateDistance();
                        break;

                    case 12:
                        Permutation.PermutationNumber();
                        break;

                    case 13:
                        StopWatch.Watch();
                        break;

                    case 14:
                        Tic_Tac_Toe.Tic_tac_toe();
                        break;

                    case 15:
                        QudraticEquation.Equation();
                        break;

                    case 16:
                        WindChill.Wind();
                        break;

                    default:
                        Console.WriteLine("enter the valid choose");
                        break;
                    }

                    Console.WriteLine("do you want continue");
                    yes = Console.ReadLine();
                }   while (choose != 0 && yes != "no");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                int  choice;
                char ch = 'Y';
                do
                {
                    Console.WriteLine(" 0. Exit\n 1. ReplaceString_Program \n 2.HeadsTails_program" +
                                      " \n 3. Leapyear_Program\n 4. CalculatePower_Program \n 5. HarmonicProgram_Program \n " +
                                      "6. PrimeFactors_Program \n 7. Gambler_Program \n 8. CouponNumbers_Program \n 9. TwoDimensionalArray_Program " +
                                      "\n 10. TripleElementAddition_Program \n 11. EuclidianDistance_Program \n 12. PermutationString_Program \n 13. CalculateElapsedTime_Program" +
                                      " \n 14. TicTacToe_Program \n 15. QuadraticFunction_Program \n 16. WindChill_Program");
                    Console.WriteLine("Enter Your Choice");
                    choice = Convert.ToInt32(Console.ReadLine());

                    switch (choice)
                    {
                    case 1:
                        ReplaceString.Replaceletter();
                        break;

                    case 2:
                        HeadsTails.Tosscoin();
                        break;

                    case 3:
                        Leapyear.CheckleapYear();
                        break;

                    case 4:
                        CalculatePower.PowerFunction();
                        break;

                    case 5:
                        HarmonicProgram.Hormonic();
                        break;

                    case 6:
                        PrimeFactors.Primefactor();
                        break;

                    case 7:
                        Gambler.GamblerGame();
                        break;

                    case 8:
                        CouponNumbers.Generatecoupon();
                        break;

                    case 9:
                        TwoDimensionalArray.InputArray();
                        break;

                    case 10:
                        TripleElementAddition.Triple();
                        break;

                    case 11:
                        Distance.CalculateDistance();

                        break;

                    case 12:
                        PermutationString.Permutation();
                        break;

                    case 13:
                        CalculateElapsedTime.ElapsedTimeDifferent();
                        break;

                    case 14:
                        TicTicGame.GameForTicTic();
                        break;

                    case 15:
                        QuadraticFunction.QuadraticMethods();
                        break;

                    case 16:
                        WindChill.CalculateWindChill();
                        break;

                    default:
                        Console.WriteLine("Case not valid plese try again");
                        break;
                    }
                    Console.WriteLine("Enter Y / N For continue:");
                    ch = Convert.ToChar(Console.ReadLine());
                }while (ch != 'N');
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        static void Main(string[] args)
        {
            ReplaceString rs          = new ReplaceString();
            FlipCoin      fc          = new FlipCoin();
            LeapYear      ly          = new LeapYear();
            Harmonic      harmonic    = new Harmonic();
            PowerOfTwo    powerOfTwo  = new PowerOfTwo();
            Factors       factors     = new Factors();
            Gambler       gambler     = new Gambler();
            CouponNumber  coupon      = new CouponNumber();
            SumOfThree    sumOfThree  = new SumOfThree();
            Distance      distance    = new Distance();
            Array2D       array       = new Array2D();
            StopWatch     stopWatch   = new StopWatch();
            Quadratic     quadratic   = new Quadratic();
            WindChill     wind        = new WindChill();
            Permutation   permutation = new Permutation();
            TicTacToe     ttt         = new TicTacToe();

            Console.WriteLine("1.ReplaceString");
            Console.WriteLine("2.FlipCoin");
            Console.WriteLine("3.LeapYear");
            Console.WriteLine("4.PowerOfTwo");
            Console.WriteLine("5.HarmonicNumber");
            Console.WriteLine("6.PrimeFactors");
            Console.WriteLine("7.Gambler");
            Console.WriteLine("8.Coupon Number");
            Console.WriteLine("9.Array2D");
            Console.WriteLine("10.SumOfThree");
            Console.WriteLine("11.Distance");
            Console.WriteLine("12.StopWatch");
            Console.WriteLine("13.Quadratic");
            Console.WriteLine("14.WindChill");
            Console.WriteLine("15. Permutation");
            Console.WriteLine("16.TicTacToe");
            Console.WriteLine("please enter the programe number which you want to execute");
            int choice = Utility.ReadInteger();

            switch (choice)
            {
            case 1: Console.WriteLine(rs.ReplaceStrings());
                break;

            case 2: fc.FlipCoins();
                break;

            case 3: ly.LeapYears();
                break;

            case 4: powerOfTwo.PowerOf2();
                break;

            case 5: harmonic.HarmonicNumber();
                break;

            case 6: factors.PrimeFactors();
                break;

            case 7: gambler.StartGambler();
                break;

            case 8: CouponNumber.GenerateCouponNumber();
                break;

            case 9: array.readArray();
                break;

            case 10: sumOfThree.GenerateSumOfThree();
                break;

            case 11: distance.CalculateDistance();
                break;

            case 12: stopWatch.CalculateElapsedTime();
                break;

            case 13: quadratic.CalculateRoots();
                break;

            case 14: wind.CalculateWindChill();
                break;

            case 15: permutation.StringPermutation();
                break;

            case 16: ttt.TicTacToeFunction();
                break;
            }
        }
        /// <summary>
        /// Defines the entry point of the application.
        /// Main method is used to take user choice to perform operations
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Boolean flag = false;

            while (flag == false)
            {
                //choice variable stores the choice of user
                int choice;
                try
                {
                    do
                    {
                        //Read choice of Operations which user wants to perform
                        Console.WriteLine("\n 1.Find Triplets \t 2.Distance \t 3.Quadratic \t 4.Wind Chill \t 5.2D Array \t 6.Exit\n Enter your Choice:");
                        choice = Convert.ToInt32(Console.ReadLine());
                        switch (choice)
                        {
                        case 1:
                            //if user wants to find triplets which exactly sum 0
                            SumOfThreeInt sumOfThreeInt = new SumOfThreeInt();
                            sumOfThreeInt.PrintSumOfThreeInt();
                            flag = true;
                            break;

                        case 2:
                            //if user wants to find Distance
                            Distance distance = new Distance();
                            distance.PrintDistance();
                            flag = true;
                            break;

                        case 3:
                            //if user wants to find roots of the equation
                            Quadratic quadratic = new Quadratic();
                            quadratic.PrintQuadratic();
                            flag = true;
                            break;

                        case 4:
                            //if user wants to calculate wind chill
                            WindChill wind = new WindChill();
                            wind.PrintWindChill();
                            flag = true;
                            break;

                        case 5:
                            //if user wants to Print values in 2D Array into file
                            TwoDArray twoDArray = new TwoDArray();
                            twoDArray.PrintTwoDArray();
                            flag = true;
                            break;

                        case 6:
                            //if user wants to Exit
                            flag = true;
                            break;

                        default:
                            Console.WriteLine("Please enter Correct Choice");
                            break;
                        }
                    } while (choice != 6);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Please enter Correct Choice");
                    flag = false;
                }
            }
            Console.ReadKey();
        }
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The command line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                string[] programs =
                {
                    "Username",       "Head&Tails",   "LeapYear",     "TableforPowerof2 COMMAND LINE ARGUMENTS NEEDED",
                    "HarmonicNumber", "PrimeFactors", "Gambler",      "CouponNumber",                                  "2dArray",
                    "Sumof3toZero",   "Distance",     "Permutations", "StopWatch",                                     "TicTacToe", "Quadratic",
                    "WindChill COMMAND LINE ARGUMENTS NEEDED"
                };
                int i, number;
                for (i = 0; i < programs.Length; i++)
                {
                    Console.WriteLine("Enter {0} for {1}", i + 1, programs[i]);
                }

                int flag = 1;
                do
                {
                    for (i = 0; i < programs.Length; i++)
                    {
                        Console.WriteLine("Enter {0} for {1}", i + 1, programs[i]);
                    }

                    Console.WriteLine();
                    Console.WriteLine("Enter question number of program to execute it and Enter 0 to close");
                    try
                    {
                        number = Convert.ToInt32(Console.ReadLine());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        Console.WriteLine("Please try entering value again again");
                        number = Utility.IsInteger(Console.ReadLine());
                    }

                    Console.WriteLine("num : {0}", number);
                    switch (number)
                    {
                    case 0:
                        return;

                    case 1:
                        UserName f = new UserName();
                        f.UserInput();
                        break;

                    case 2:
                        FlipCoin c = new FlipCoin();
                        c.Toss();
                        break;

                    case 3:
                        LeapYear ly = new LeapYear();
                        ly.Leap();
                        break;

                    case 4:
                        PowerOfTwo p = new PowerOfTwo();
                        p.PowerTwo(Convert.ToInt32(args[0]));
                        break;

                    case 5:
                        Harmonic h = new Harmonic();
                        h.NHarmonic();
                        break;

                    case 6:
                        PrimeFactors fa = new PrimeFactors();
                        fa.PrimeFactorsfor();
                        break;

                    case 7:
                        Gambler g = new Gambler();
                        g.GamblerGame();
                        break;

                    case 8:
                        Coupon co = new Coupon();
                        co.CouponGame();
                        break;

                    case 9:
                        ArrayTwoDim atd = new ArrayTwoDim();
                        atd.Array2D();
                        break;

                    case 10:
                        ZeroTriplets zt = new ZeroTriplets();
                        zt.Triplets();
                        break;

                    case 11:
                        Distance di = new Distance();
                        di.SqrtDistance();
                        break;

                    case 12:
                        Permutations pe = new Permutations();
                        pe.StringPermutations();
                        break;

                    case 13:
                        StopWatch sw = new StopWatch();
                        sw.StopWatchDemo();
                        break;

                    case 14:
                        TicTacToe tt = new TicTacToe();
                        tt.TicTacToeDemo();
                        break;

                    case 15:
                        Quadratic q = new Quadratic();
                        q.QuadraticDemo();
                        break;

                    case 16:
                        WindChill wc = new WindChill();
                        wc.WindChillDemo(Convert.ToDouble(args[1]), Convert.ToDouble(args[2]));
                        break;

                    default:
                        Console.WriteLine("Not yet created");
                        flag = 0;
                        break;
                    }

                    Console.ReadKey();
                    Console.Clear();
                }while (flag == 1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Main function
        /// </summary>
        /// <param name="args">args parameter</param>
        public static void Main(string[] args)
        {
            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("Enter 1: ReplaceString");
                Console.WriteLine("Enter 2: FlipCoin");
                Console.WriteLine("Enter 3: LeapYear");
                Console.WriteLine("Enter 4: PowerOf2");
                Console.WriteLine("Enter 5: HarmonicNumber");
                Console.WriteLine("Enter 6: PrimeFactors");
                Console.WriteLine("Enter 7: TwoDimensionArray");
                Console.WriteLine("Enter 8: SumOfThreeInteger");
                Console.WriteLine("Enter 9: Distance");
                Console.WriteLine("Enter 10: Quadratic");
                Console.WriteLine("Enter 11: WindChill");
                Console.WriteLine("Enter 0: To Exit");
                Console.WriteLine();

                string input    = Console.ReadLine();
                bool   isAllInt = input.All(char.IsDigit);
                if (isAllInt)
                {
                    long num = Convert.ToInt64(input);
                    switch (num)
                    {
                    case 1:
                        ReplaceString.Replaceword();
                        break;

                    case 2:
                        FlipCoin.FlipCoinFunction();
                        break;

                    case 3:
                        LeapYear.LeapYearFunction();
                        break;

                    case 4:
                        PowerOf2.PowerOf2Function();
                        break;

                    case 5:
                        HarmonicNumber.HarmonicNumberFunction();
                        break;

                    case 6:
                        PrimeFactors.PrimeFactorFunction();
                        break;

                    case 7:
                        TwoDimensionArray.TwoDimensionArrayFunction();
                        break;

                    case 8:
                        SumOfThreeInteger.SumOfThreeFunction();
                        break;

                    case 9:
                        Distance.DistanceFunction();
                        break;

                    case 10:
                        Quadratic.QuadraticFunction();
                        break;

                    case 11:
                        WindChill.WindChillFunction();
                        break;

                    case 0:
                        exit = true;
                        break;

                    default:
                        Console.WriteLine("Invalid Input");
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Enter valid digit");
                }

                Console.WriteLine();
            }
        }