Пример #1
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');
        }
Пример #2
0
        /// <summary>
        /// Mains the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            Console.WriteLine("Please select your choice from the giving list: ");
            Console.WriteLine("1. Username");
            Console.WriteLine("2. Flip Coin");
            Console.WriteLine("3. Leap Year");
            Console.WriteLine("4. Power of two");
            Console.WriteLine("5. Harmonic Number");
            Console.WriteLine("6. Factors");
            Console.WriteLine("8. Coupon Number");
            Console.WriteLine("9. 2D Array");
            Console.WriteLine("10. Sum of three Integer adds to ZERO");

            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case 1:

                Username.CheckUsername();
                Console.ReadKey();
                break;

            case 2:
                Utility.GetInt();
                FlipCoin.FlipCoinResult();
                Console.ReadKey();
                break;

            case 3:
                Utility.InputYear();
                LeapYear.CheckLeap();
                Console.ReadKey();
                break;

            case 4:
                Utility.GetInt();
                PowerOf2.TableOf2();
                Console.ReadKey();
                break;

            case 5:
                Utility.GetInt();
                HarmonicValue.HarmonicSum();
                Console.ReadKey();
                break;

            case 6:

                Utility.GetInt();
                Factors.PrimeFactor();
                Console.ReadKey();
                break;

            case 8:

                Utility.GetInt();
                CouponNumber.DistinctCoupon();
                Console.ReadKey();
                break;

            case 9:

                TwoDimentionalArray.WriteArray();
                Console.ReadKey();
                break;

            case 10:
                Utility.GetInt();
                Triplets.FindTriplets();
                Console.ReadKey();
                break;
            }
        }
Пример #3
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;
            }
        }
Пример #4
0
        /// <summary>
        /// main method is a entry point
        /// </summary>
        /// <param name="args">The arguments.</param>
        static void Main(string[] args)
        {
            Utility util = new Utility();

            Console.WriteLine("List Of Programs....");
            Console.WriteLine("1. To Find the ReplaceString" + "\n2. To Find the Flip Coin" + "\n3. To Find theLeap year"
                              + "\n4. To find the Power Of 2" + "\n5. To find the Nth Harmonic Value" + "\n6. To Find the Prime Factor"
                              + "\n7. To Play the Gambler Game" + "\n8. To Genrate the Coupon Number" + "\n9. 2D Array"
                              + "\n10. Sum of Triplet In Array" + "\n11. Find the Euclidean Distance" + "\n13. Get Elapsed Time In Stop Watch" + "\n15. Find the Root Of Quadratic Equation"
                              + "\n16. To calculate the WindChill");
            Console.WriteLine("Enter Your Choice");
            try
            {
                int choice = Convert.ToInt32(Console.ReadLine());
                ////here switch is used to operate the program through user choice and for them making raltive object class
                ///and call their method to perform the operation
                switch (choice)
                {
                case 1:
                    Console.WriteLine("\nReplace String Operation to be Performed :");
                    ReplaceString replaceString = new ReplaceString();
                    replaceString.Replace();
                    break;

                case 2:
                    Console.WriteLine("\nFlip coin Operation to be Performed :");
                    FlipCoin flipCoin = new FlipCoin();
                    flipCoin.Flip();
                    break;

                case 3:
                    Console.WriteLine("\nLeap Year Operation to be Performed :");
                    LeapYear leapy = new LeapYear();
                    leapy.Leap();
                    break;

                case 4:
                    Console.WriteLine("\nFinding Power of 2 Operation to be Performed :");
                    PowerOf2 power2 = new PowerOf2();
                    power2.Power();
                    break;

                case 5:
                    Console.WriteLine("\nFinding Harmonic Number Operation to be Performed :");
                    HarmonicNumber number = new HarmonicNumber();
                    number.Harmonic();
                    break;

                case 6:
                    Console.WriteLine("\nFinding Prime Number Operation to be Performed :");
                    PrimeFactor prime = new PrimeFactor();
                    prime.Factor();
                    break;

                case 7:
                    Console.WriteLine("\nPlay the Gambler game:");
                    Gambler gambler = new Gambler();
                    gambler.Play();
                    break;

                case 8:
                    Console.WriteLine("\nFinding Distinct Coupon Number Operation to be Performed :");
                    Coupon coupon = new Coupon();
                    Console.WriteLine("Enter the Number to genrate Distinct Coupon Number");
                    int n     = util.InputInteger();
                    int count = coupon.Collect(n);
                    Console.WriteLine("Total count of distinct coupon Number is :" + count);
                    break;

                case 9:
                    Console.WriteLine("\n2D Array Operation to be Performed :");
                    Console.WriteLine("Enter the Number of Rows");
                    int r = util.InputInteger();
                    Console.WriteLine("Enter the Number of Columns");
                    int       co     = util.InputInteger();
                    TwoDArray dArray = new TwoDArray();
                    int[,] arrInt1       = dArray.ArrayInteger(r, co);
                    double[,] arrDouble1 = dArray.Arraydouble(r, co);
                    bool[,] arrBool1     = dArray.ArrayBoolean(r, co);
                    dArray.Display(arrInt1, arrDouble1, arrBool1, r, co);
                    break;

                case 10:
                    Console.WriteLine("\nFinding Triplet sum will be Zero In Array Operation to be Performed :");
                    Console.WriteLine("Enter the Number in how many Element you want to check");
                    int        num = util.InputInteger();
                    SumOfArray sum = new SumOfArray();
                    sum.ArraySum(num);
                    break;

                case 11:
                    Console.WriteLine("\nFinding Ecludian Distance Operation to be Performed :");
                    Console.WriteLine("Enter the first cordinate of distance");
                    int x = util.InputInteger();
                    Console.WriteLine("Enter the Second Cordinate of distance");
                    int      y        = util.InputInteger();
                    Distance distance = new Distance();
                    distance.EcludianDistance(x, y);
                    break;

                case 12:
                    Console.WriteLine("\nFinding Permutation of String Operation to be Performed :");
                    Console.WriteLine("Enter the string Which you want to Find the Permutation");
                    Permutation permute = new Permutation();
                    permute.PermutateString();
                    break;

                case 13:
                    Console.WriteLine("\nFinding Elapsed time in stop watch Operation to be Performed :");
                    StopWatch stop = new StopWatch();
                    Console.WriteLine("Enter 1 for start the Timer");
                    int h = util.InputInteger();
                    stop.Start();
                    Console.WriteLine("Enter 2 for stop the Timer");
                    int h1 = util.InputInteger();
                    stop.Stop();
                    long l = stop.GetElapsedTime();
                    Console.WriteLine("Elapsed time in milliSecond is: " + l);
                    break;

                case 14:
                    TicTacToe tic = new TicTacToe();
                    tic.play();
                    break;

                case 15:
                    Console.WriteLine("\nFinding Quadratic Roots  Operation to be Performed :");
                    Console.WriteLine("Enter Value of a To finding the Roots");
                    int a = util.InputInteger();
                    Console.WriteLine("Enter Value of b To finding the Roots");
                    int b = util.InputInteger();
                    Console.WriteLine("Enter Value of c To finding the Roots");
                    int        c    = util.InputInteger();
                    Quuadratic Root = new Quuadratic();
                    Root.FindRoot(a, b, c);
                    break;

                case 16:
                    Console.WriteLine("\nConverting Temperature in Degree Celsicius to Farenhite And Vice Versa Operation to be Performed :");
                    Console.WriteLine("Enter the temperature in Farenhite");
                    double t = util.InputDouble();
                    Console.WriteLine("Enter the Wind Speed In Miles Per Hour");
                    double    v     = util.InputDouble();
                    WindMills wind1 = new WindMills();
                    wind1.Wind(t, v);
                    break;
                }
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #5
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;
            }
        }