コード例 #1
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);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            int flag = 1;

            do
            {
                Console.WriteLine();
                Console.WriteLine("Enter question number of program to execute it and Enter 0 to close");
                int number = Utility.IsInteger(Console.ReadLine());
                Console.WriteLine("num : {0}", number);
                switch (number)
                {
                case 0:
                    return;

                case 1:
                    UserName f = new UserName();
                    f.UserInput();
                    Console.ReadLine();
                    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;

                default:
                    Console.WriteLine("Not yet created");
                    Console.ReadLine();
                    flag = 0;
                    break;
                }
            } while (flag == 1);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Girihub/Core-Program
        /// <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();
            }
        }
コード例 #4
0
        /// <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);
            }
        }
コード例 #5
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            int  option = -1;   ///option for choosing a number from menu.
            bool flag   = true; ///flag for keep looping untill a valid option from the existing menu is choose.

            while (flag)
            {
                Console.WriteLine("======================================================================================================================");
                Console.WriteLine("Select the program from below .Enter 0 to exit");
                Console.WriteLine("1) Replace String Template");
                Console.WriteLine("2) CoinFlip");
                Console.WriteLine("3) LeapYear");
                Console.WriteLine("4) Power Of 2");
                Console.WriteLine("5) Harmonic value");
                Console.WriteLine("6) Prime Factors");
                Console.WriteLine("7) Gambler");
                Console.WriteLine("8) Sum Of Triplets to 0");
                Console.WriteLine("9) Distance");
                Console.WriteLine("======================================================================================================================");

                try
                {
                    option = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid Command");
                    continue;
                }

                switch (option)
                {
                case 0:
                {
                    flag = false;
                    break;
                }

                case 1:
                {
                    ReplaceString.ReplaceName();
                    break;
                }

                case 2:
                {
                    CoinFlip.FlipCoin();
                    break;
                }

                case 3:
                {
                    LeapYear.CheckLeapYear();

                    break;
                }

                case 4:
                {
                    PowerOf2.PowerOfTwo();
                    break;
                }

                case 5:
                {
                    HarmonicNumbers.GetHarmonicValue();
                    break;
                }

                case 6:
                {
                    PrimeFactors.GetPrimeFactors();
                    break;
                }

                case 7:
                {
                    Gambler.GamblerPlay();
                    break;
                }

                case 8:
                {
                    Triplets.FindTriplet();
                    break;
                }

                case 9:
                {
                    Distance.CalculateEuclideanDistance();

                    break;
                }

                default:
                {
                    Console.WriteLine("Invalid Option");
                    break;
                }
                }
            }
        }