Esempio n. 1
0
        static void Main(string[] args)
        {
            int comp_mind = ISSMath.RNDInt(9);

            Console.WriteLine("In my mind=" + comp_mind);
            int yourguess;
            int count = 0;

            do
            {
                if (count >= 1)
                {
                    Console.WriteLine("Try again");
                }
                yourguess = ISSConsole.ReadInt("Guess the number in my mind");
                ++count;
            } while (comp_mind != yourguess);
            if (count <= 2)
            {
                Console.WriteLine("Congrats. you have made {0} attempts", count);
                Console.WriteLine("You are a wizard");
            }
            else if (count >= 3 && count <= 5)
            {
                Console.WriteLine("You are a good guess");
            }
            else
            {
                Console.WriteLine("Your are lousy");
            }
        }
Esempio n. 2
0
        public static void Ex33()
        {
            int temp;
            int n = ISSConsole.ReadInt("Please insert length of array: ");

            int[] array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = ISSMath.RNDInt(100);
                Console.Write($"\t{array[i]}");
            }
            Console.WriteLine();
            Console.WriteLine("Simplified seclection sort method progess:");
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if (array[i] < array[j])
                    {
                        temp     = array[i];
                        array[i] = array[j];
                        array[j] = temp;
                        for (int l = 0; l < n; l++)
                        {
                            Console.Write($"\t{array[l]}");
                        }
                        Console.WriteLine();
                    }
                }
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            int a, rnd, i;

            i = 0;
            do
            {
                rnd = ISSMath.RNDInt(9);
                Console.WriteLine("Enter number?");
                a = Convert.ToInt32(Console.ReadLine());
                i++;
            } while (rnd != a);
            if (i < 3)
            {
                Console.WriteLine("Times {0}.", i);
                Console.WriteLine("You are a Wizard!");
            }
            else if (i >= 3 && i < 6)
            {
                Console.WriteLine("Times {0}.", i);
                Console.WriteLine("You are lousy!");
            }
            else
            {
                Console.WriteLine("Times {0}.", i);
                Console.WriteLine("Try Again!");
            }
        }
Esempio n. 4
0
        public static void Ex22()
        {
            int RandomInteger = ISSMath.RNDInt(10);

            Console.WriteLine("Welcome to the Guess the Number Game!!");
            Console.WriteLine("Please insert a number (0~9): ");
            int count = 0;
            int guess;

            do
            {
                guess = ISSConsole.ReadInt();
                if (guess != RandomInteger)
                {
                    Console.WriteLine("Please try again!");
                    count++;
                }
                else
                {
                    if (count <= 1)
                    {
                        Console.WriteLine("You are a Wizard!");
                    }
                    else if (count <= 4)
                    {
                        Console.WriteLine("You are a good guess!");
                    }
                    else if (count <= 9)
                    {
                        Console.WriteLine("You are lousy!");
                    }
                }
            }while (guess != RandomInteger);
        }
Esempio n. 5
0
        public static void Ex35()
        {
            int sumClass;

            int[,] student = new int[12, 4];

            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    student[i, j] = ISSMath.RNDInt(100);
                }
            }
            sumClass = 0;
            Console.WriteLine("\t\t\tSubject1\tSubject2\tSubject3\tSubject4\tTotal\tAverage");
            for (int i = 0; i < 12; i++)
            {
                Console.Write($"Student{i + 1}");
                int sum = 0;
                for (int j = 0; j < 4; j++)
                {
                    Console.Write($"\t\t{student[i, j]}");
                    sum += student[i, j]; //?
                }
                Console.Write($"\t\t{sum}\t{(double)sum / 4:0.##}");
                Console.WriteLine();
                sumClass += sum;
            }
            Console.WriteLine();
            Console.Write("Sub Average");
            double[] subAverage = new double[4];
            for (int j = 0; j < 4; j++)
            {
                int subSum = 0;
                for (int i = 0; i < 12; i++)
                {
                    subSum += student[i, j];
                }
                subAverage[j] = (double)subSum / 12;
                Console.Write($"\t\t{subAverage[j]:0.##}");
            }
            Console.WriteLine();

            //Find Deviation:
            Console.Write("Deviation");
            double[] deviation = new double[4];
            for (int j = 0; j < 4; j++)
            {
                double sumVariance = 0;
                for (int i = 0; i < 12; i++)
                {
                    sumVariance += Math.Pow((student[i, j] - subAverage[j]), 2);
                }
                deviation[j] = (double)Math.Sqrt(sumVariance / 12);
                Console.Write($"\t\t{deviation[j]:0.##}");
            }
            Console.WriteLine();
            Console.WriteLine($"Class average: {(double)sumClass / (12 * 4):0.##}");
        }
Esempio n. 6
0
        public static void SQT(int n)
        {
            double g = ISSMath.RND();

            while (g * g != n)
            {
                g = (g + n / g) / 2;
            }
            Console.WriteLine($"Squart root of {n} is {g}");
        }
Esempio n. 7
0
        public static void Ex24()
        {
            int    n = ISSConsole.ReadInt("Please input number to find it's squart root: ");
            double g = ISSMath.RND();

            while (g * g != n)
            {
                g = (g + n / g) / 2;
            }
            Console.WriteLine($"Squart root of {n} is {g}");
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            int comp_mind = ISSMath.RNDInt(9);
            int yourguess;
            int count = 0;

            do
            {
                yourguess = ISSConsole.ReadInt("Guess the number in my mind");
                ++count;
            } while (comp_mind != yourguess);
            Console.WriteLine("Congrats. your have made {0} attempts", count);
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            int n = 0;

            Console.WriteLine("Enter a number to find square root");
            //Random r = new Random();
            //Console.Write("Random"+r.Next(9));
            n = ISSConsole.ReadInt();
            int g = ISSMath.RNDInt(n);
            int sqrt;

            while (g * g != n)
            {
                g = (g + (n / g)) / 2;
            }
            sqrt = g;
            Console.WriteLine("The square root of {0} is {1}", n, sqrt);
        }
Esempio n. 10
0
        public static void Ex34()
        {
            int maxIndex = 0;
            int max;
            int n = ISSConsole.ReadInt("Please insert length of array: ");

            int[] array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = ISSMath.RNDInt(100);
                Console.Write($"\t{array[i]}");
            }
            Console.WriteLine();
            max = array[0];
            Console.WriteLine("Refined selection sort method progess:");
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if (array[j] > max)
                    {
                        max      = array[j];
                        maxIndex = j;
                    }
                }
                //swap:
                array[maxIndex] = array[i];
                array[i]        = max;
                for (int l = 0; l < n; l++)
                {
                    Console.Write("\t" + array[l]);
                }
                Console.WriteLine($"\tMax= {max}");
                max      = array[i + 1];
                maxIndex = i + 1;
            }
        }
Esempio n. 11
0
 public void throwDice()
 {
     faceUP = ISSMath.RNDInt(6) + 1;
 }
Esempio n. 12
0
File: Die.cs Progetto: E0046785/oop
 public void Throw()
 {
     faceUp = ISSMath.RNDInt(6) + 1;
 }
Esempio n. 13
0
 public void Flip()
 {
     face = ISSMath.RNDInt(2);
 }
Esempio n. 14
0
 //Methods
 public void Throw()
 {
     faceUp = ISSMath.RNDInt(6) + 1; //returns random int frm 1 to 6
 }
Esempio n. 15
0
File: Dice.cs Progetto: E0046479/OOP
 public int Throw()
 {
     faceUp = ISSMath.RNDInt(6) + 1;
     return(faceUp);
 }
Esempio n. 16
0
 public void Throw()
 {
     faceup = ISSMath.RNDInt(6);
 }