Page 362 - ComputerScience_Class_11
P. 362

5               int[] numbers = {5, 2, 9, 1, 7};
                 6               int max = numbers[0];

                 7               int min = numbers[0];
                 8               for (int i = 1; i < numbers.length; i++)

                 9               {
                10                   if (numbers[i] > max)

                11                   {
                12                       max = numbers[i];

                13                   }

                14                   if (numbers[i] < min)
                15                   {

                16                       min = numbers[i];
                17                   }

                18               }
                19               System.out.println("Maximum value: " + max);

                20               System.out.println("Minimum value: " + min);

                21           }
                22       }

              The output of the preceding program is as follows:
                      BlueJ: Terminal Window - Java

                   Options
                  Maximum value: 9

                  Minimum value: 1



                   11.14 SOLVING SYSTEMS OF LINEAR EQUATIONS IN TWO VARIABLES
              To solve a system of linear equations, you can use various methods, such as substitution, elimination or matrix methods.
              Cramer's Rule provides a method to solve a system of linear equations using determinants. The formula for solving a
              system of linear equations with n variables is as follows:
              A system of linear equations with two variables can be written as:
              •  a x + b y = c 1
                  1
                       1
              •  a x + b y = c 2
                  2
                       2
                Where
                x and y are the variables,
                a , a , b , b , c , c  are constants
                        1
                                2
                              1
                           2
                  1
                     2
              To solve such a system of equations, we can use methods like substitution, elimination or Cramer's Rule.
                  360  Touchpad Computer Science (Ver. 3.0)-XI
   357   358   359   360   361   362   363   364   365   366   367