Esempio n. 1
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        static void Main(string[] args)
        {
            Console.WriteLine("1: Replace String");
            Console.WriteLine("2: FlipCoin");
            Console.WriteLine("3: Leap Year");
            Console.WriteLine("4: Power of 2");
            Console.WriteLine("5: Harmonic Number");
            Console.WriteLine("6: Prime Factors");
            Console.WriteLine("7: Gambler");
            Console.WriteLine("8: Coupon Numbers");
            Console.WriteLine("9: 2D Array");
            Console.WriteLine("10: Sum of Integer Zero");
            Console.WriteLine("11: Distance");
            Console.WriteLine("12: Permutations");
            Console.WriteLine("13: Stop Watch");
            Console.WriteLine("14: Tic-Tac-Toe");
            Console.WriteLine("15: Quadratic");
            Console.WriteLine("16: Wind Chill");
            int choice = 0;

            while (!(choice > 0 && choice < 17))
            {
                try
                {
                    Console.Write("Enter your choice: ");
                    choice = Convert.ToInt32(Console.ReadLine());
                }
                catch (FormatException)
                {
                    //Console.WriteLine(Ex);
                }
            }

            //Console.WriteLine(choice);
            switch (choice)
            {
            case 1:
                ReplaceString replaceString = new ReplaceString();
                replaceString.Print();
                break;

            case 2:
                FlipCoin flip = new FlipCoin();
                flip.flipCoin();
                break;

            case 3:
                LeapYear leap = new LeapYear();
                leap.leapYear();
                break;

            case 4:
                PowerOfTwo powerOfTwo = new PowerOfTwo();
                powerOfTwo.printPowerOfTwo();
                break;

            case 5:
                HarmonicNumber harmonic = new HarmonicNumber();
                harmonic.printHarmonicNumber();
                break;

            case 6:
                Factors factors = new Factors();
                factors.printFactors();
                break;

            case 7:
                Gambler gambler = new Gambler();
                gambler.gambling();
                break;

            case 8:
                CouponNumbers coupon = new CouponNumbers();
                coupon.CouponCode();
                break;

            case 9:
                TwoDArray array = new TwoDArray();
                array.input();
                break;

            case 10:
                SumZero sumZero = new SumZero();
                sumZero.checkSumForZero();
                break;

            case 11:
                Distance distance = new Distance();
                distance.calculateDistance();
                break;

            case 12:
                Permutations permutations = new Permutations();
                permutations.permutation();
                break;

            case 13:
                StopWatch watch = new StopWatch();
                watch.simulate();
                break;

            case 14:
                TicTacToe ticTacToe = new TicTacToe();
                ticTacToe.game();
                break;

            case 15:
                Quadratic quadratic = new Quadratic();
                quadratic.roots();
                break;

            case 16:
                WindChill windChill = new WindChill();
                int       t         = 100;
                int       v         = 0;
                while (!(Math.Abs(t) <= 50 && v <= 120 && v >= 3))
                {
                    Console.WriteLine("Enter Temperature and Wind Speed: ");
                    t = Convert.ToInt32(Console.ReadLine());
                    v = Convert.ToInt32(Console.ReadLine());
                }
                windChill.calculateEffectiveTemperature(t, v);
                break;

            default:
                Console.WriteLine("Wrong Choice!");
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Defines the entry point of the application
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            char condition;

            do
            {
                Console.WriteLine("PRESS 1   :   TO REPLACE THE STRING NAME");
                Console.WriteLine("PRESS 2   :   TO FLIPCOIN THE NUMBER");
                Console.WriteLine("PRESS 3   :   TO ENTER THE 4 DIGIT NUMNER");
                Console.WriteLine("PRESS 4   :   TO  ENTER POWER OF 2");
                Console.WriteLine("PRESS 5   :   TO ENTER THE NUMBER TO HARMONIC");
                Console.WriteLine("PRESS 6   :   TO ENTER THE NUMBER TO PRIMEFACOR");
                Console.WriteLine("PRESS 7   :   TO ENTER THE NUMBERS OF GAMBLERS");
                Console.WriteLine("PRESS 8   :   TO ENTER THE COUPONS NUMBER");
                Console.WriteLine("PRESS 9   :   TO ENTER THE ARRAYS ELEMENTS");
                Console.WriteLine("PRESS 10  :   SUM OF THREE DIGIT ADD INTO ZEROS");
                Console.WriteLine("PRESS 11  :   FINDING THE DISTANCE FROM POINT TO ORIGION");
                Console.WriteLine("PRESS 12  :   FINDING THE PERMUTATIONS STRING");
                Console.WriteLine("PRESS 13  :   TO STOPWATCH");
                Console.WriteLine("PRESS 14  :   TO TIK TOC PROBLES ");
                Console.WriteLine("PRESS 15  :   TO QUEDRATIC ROOT");
                Console.WriteLine("PRESS 16  :   TO Windchill prg");
                int num = Convert.ToInt32(Console.ReadLine());
                switch (num)
                {
                case 1:
                    ReplaceString rs = new ReplaceString();
                    rs.ReplaceString1();
                    break;

                case 2:
                    FlipCoin fp = new FlipCoin();
                    fp.Flip();
                    break;

                case 3:
                    LeapYear lp = new LeapYear();
                    lp.Leapyear();
                    break;

                case 4:
                    PowerOf2 p2 = new PowerOf2();
                    p2.PowersOf2();
                    break;

                case 5:
                    Harmonicnum hn = new Harmonicnum();
                    hn.Harmonic();
                    break;

                case 6:
                    PrimeFactor pf = new PrimeFactor();
                    pf.Prime_Factors();
                    break;

                case 7:
                    Gamblers g = new Gamblers();
                    g.Gambler1();
                    break;

                case 8:
                    Coupons cp = new Coupons();
                    cp.CouponNum();
                    break;

                case 9:
                    Arrays2 arr = new Arrays2();
                    arr.Array2D();
                    break;

                case 10:
                    AddToZeros atz = new AddToZeros();
                    atz.Add3NumbersToZero();
                    break;

                case 11:
                    Distance d = new Distance();
                    d.DistanceToOrigin();
                    break;

                case 12:
                    Permutations pr = new Permutations();
                    pr.StartPermutation();
                    break;

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

                case 14:
                    TicTacToe ttt = new TicTacToe();
                    ttt.TicTocToeGame();
                    break;

                case 15:
                    Quedratic qd = new Quedratic();
                    qd.Roots();
                    break;

                case 16:
                    WindChill wc = new WindChill();
                    wc.CalculateWindChill();
                    break;
                }

                Console.WriteLine("ENTER Y TO CONTINUES N TO STOP ");
                condition = Convert.ToChar(Console.ReadLine());
            }while (condition == 'y');
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the no of the program which you want to run from the given programs");
            Console.WriteLine("2d Array(1)");
            Console.WriteLine("Replace the string(2)");
            Console.WriteLine("Flip a Coin(3)");
            Console.WriteLine("Cheak wheather the year is leap year or not(4)");
            Console.WriteLine("Power of 2(5)");
            Console.WriteLine("Find nth Harmonic no(6)");
            Console.WriteLine("Find the Factor of a no(7)");
            Console.WriteLine("Generate Distinct Cupon no.(8)");
            Console.WriteLine("Gambler Game(9)");
            Console.WriteLine("Triple Sum(10)");
            Console.WriteLine("Find Distance(11)");
            Console.WriteLine("Stop Watch(12)");
            Console.WriteLine("Qudratic(13)");
            Console.WriteLine("Calculate WindChill(14)");


            int p = int.Parse(Console.ReadLine());

            switch (p)
            {
            case 1:
                Console.WriteLine("Enter the row");
                int r;
                r = int.Parse(Console.ReadLine());
                Console.WriteLine("Enter the coulumn");
                int c;
                c = int.Parse(Console.ReadLine());
                Array2D a = new Array2D();
                //Calling the methods to generate 2D array by taking user input
                a.ArrayInt(r, c);
                a.ArrayDouble(r, c);
                a.ArrayBoolean(r, c);
                break;

            case 2:
                ReplaceStr b = new ReplaceStr();
                //Calling method to replace the string by the user given string
                b.ReplaceS();
                break;

            case 3:
                FlipCoin d = new FlipCoin();
                //Calling method to flip the coin and calculate the percentage
                d.CoinFlip();
                break;

            case 4:
                LeapYear e = new LeapYear();
                //Calling method to cheak whether the year is a leap year or not
                e.ChkLeapYear();
                break;

            case 5:
                PowerOfTwo f = new PowerOfTwo();
                //Calling method to calculate the power of 2 from 0 to n
                f.Powerof2();
                break;

            case 6:
                Harmonic h = new Harmonic();
                //Calling method to calculate the nth harmonic no
                h.ChkHarmonic();
                break;

            case 7:
                Factors g = new Factors();
                //Calling method to find the factors of a no
                g.FindFactors();
                break;

            case 8:
                CuponNum k = new CuponNum();
                //Calling method to generate the cupon nos
                k.Couponno();
                break;

            case 9:
                Gambler l = new Gambler();
                //Calling method to play Gambling Game
                l.GamblerG();
                break;

            case 10:
                TripleSum m = new TripleSum();
                //Calling method to find the sequence of three nos which sum is equals to 0
                m.ThreeSum();
                break;

            case 11:
                Distance n = new Distance();
                //calling method to calculate the distance between two points
                n.FindDistance();
                break;

            case 12:
                StopWatch o = new StopWatch();
                //Start the watch
                Console.WriteLine("Enter 1 to start");
                int t = int.Parse(Console.ReadLine());
                if (t == 1)
                {
                    o.Start();
                }


                //Stop and Calculate the Elapsed time
                Console.WriteLine("Enter 0 to stop");
                int t1 = int.Parse(Console.ReadLine());
                if (t1 == 0)
                {
                    o.Stop();
                }

                Console.WriteLine();
                break;

            case 13:
                Quadratic q = new Quadratic();
                //Calling Find method to find  roots
                q.Find();
                break;

            case 14:
                int       x = int.Parse(args[0]);
                int       y = int.Parse(args[0]);
                WindChill s = new WindChill();
                //calling method to calculate windchill
                s.FindWindChill(x, y);
                break;
            }
        }