Exemplo 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");
            }
        }
Exemplo n.º 2
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!");
            }
        }
Exemplo n.º 3
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();
                    }
                }
            }
        }
Exemplo 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);
        }
Exemplo 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.##}");
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
 public void throwDice()
 {
     faceUP = ISSMath.RNDInt(6) + 1;
 }
Exemplo n.º 10
0
Arquivo: Die.cs Projeto: E0046785/oop
 public void Throw()
 {
     faceUp = ISSMath.RNDInt(6) + 1;
 }
Exemplo n.º 11
0
 public void Flip()
 {
     face = ISSMath.RNDInt(2);
 }
Exemplo n.º 12
0
 //Methods
 public void Throw()
 {
     faceUp = ISSMath.RNDInt(6) + 1; //returns random int frm 1 to 6
 }
Exemplo n.º 13
0
Arquivo: Dice.cs Projeto: E0046479/OOP
 public int Throw()
 {
     faceUp = ISSMath.RNDInt(6) + 1;
     return(faceUp);
 }
Exemplo n.º 14
0
 public void Throw()
 {
     faceup = ISSMath.RNDInt(6);
 }