├── Addition. Bug Report.png ├── Addition. Bug workflow.jpg ├── Addition. Data input-output.java ├── Addition. Decision table.xlsx ├── Addition. Recursive functions.java ├── Topic 1.1.2.java ├── Topic 1.1.3.java ├── Topic 1.1.4.java ├── Topic 1.1.5.java ├── Topic 1.1.6.java ├── Topic 1.1.7.java ├── Topic 1.1.8.java ├── Topic 1.2.1.sql ├── Topic 1.2.2.sql ├── Topic 1.2.3.sql └── URLs /Addition. Bug Report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respawn91/testing2021/a9c68c8b6f75db3ab4baf0b4f0136e513e8fa210/Addition. Bug Report.png -------------------------------------------------------------------------------- /Addition. Bug workflow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respawn91/testing2021/a9c68c8b6f75db3ab4baf0b4f0136e513e8fa210/Addition. Bug workflow.jpg -------------------------------------------------------------------------------- /Addition. Data input-output.java: -------------------------------------------------------------------------------- 1 | // Вывод println() 2 | 3 | public class HelloWorld{ 4 | 5 | public static void main(String []args){ 6 | 7 | System.out.println("Hello World"); 8 | 9 | String s = "Test"; 10 | System.out.println(s); 11 | 12 | int a = 10; 13 | System.out.println(a); 14 | 15 | boolean b = true; 16 | System.out.println(b); 17 | 18 | int x = 10; 19 | int y = 20; 20 | 21 | System.out.println(x+y); 22 | 23 | System.out.println(s + a); 24 | 25 | } 26 | } 27 | 28 | // Вывод print() 29 | 30 | public class HelloWorld{ 31 | 32 | public static void main(String []args){ 33 | 34 | System.out.print("Hello World\n"); 35 | System.out.print("Hello World\t"); 36 | System.out.print("Hello World"); 37 | 38 | } 39 | } 40 | 41 | // Вывод printf() 42 | 43 | public class HelloWorld{ 44 | 45 | public static void main(String []args){ 46 | 47 | int a = 35; 48 | int b = 42; 49 | 50 | System.out.printf("%d + %d = %d\n", a, b, a + b); 51 | } 52 | } 53 | 54 | 55 | // Ввод данных 56 | 57 | import java.util.Scanner; 58 | 59 | public class HelloWorld{ 60 | 61 | public static void main(String []args){ 62 | 63 | Scanner sc = new Scanner(System.in); 64 | 65 | int x1 = sc.nextInt(); 66 | System.out.println(x1); 67 | 68 | int x2 = sc.nextInt(); 69 | System.out.println(x2); 70 | 71 | int x3 = sc.nextInt(); 72 | System.out.println(x3); 73 | 74 | int x4 = sc.nextInt(); 75 | System.out.println(x4); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Addition. Decision table.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respawn91/testing2021/a9c68c8b6f75db3ab4baf0b4f0136e513e8fa210/Addition. Decision table.xlsx -------------------------------------------------------------------------------- /Addition. Recursive functions.java: -------------------------------------------------------------------------------- 1 | // Факториал 2 | public class HelloWorld{ 3 | 4 | public static int fact1(int n) { 5 | int result = 1; 6 | 7 | if((n == 0) || (n == 1)) 8 | result = 1; 9 | else { 10 | for(int i = 1; i <= n; i++) { 11 | result = result * i; 12 | } 13 | } 14 | 15 | return result; 16 | } 17 | 18 | public static int fact2(int n) { 19 | 20 | if((n == 0) || (n == 1)) 21 | return 1; 22 | else 23 | return n*fact2(n-1); 24 | } 25 | 26 | 27 | public static void main(String []args){ 28 | 29 | System.out.println(fact1(7)); 30 | System.out.println(fact2(7)); 31 | 32 | 33 | } 34 | } 35 | 36 | 37 | // Последовательность Фибоначчи 38 | public class HelloWorld{ 39 | 40 | public static int fibb(int n) { 41 | 42 | if((n == 1) || (n == 2)) 43 | return 1; 44 | else 45 | return fibb(n-1) + fibb(n-2); 46 | } 47 | 48 | 49 | 50 | public static void main(String []args){ 51 | 52 | System.out.println(fibb(7)); 53 | 54 | for(int i = 1; i <= 10; i++) { 55 | 56 | System.out.print(fibb(i) + " "); 57 | } 58 | 59 | 60 | } 61 | } -------------------------------------------------------------------------------- /Topic 1.1.2.java: -------------------------------------------------------------------------------- 1 | // 2 | 3 | public class HelloWorld{ 4 | 5 | public static void main(String []args){ 6 | 7 | int a = 10; 8 | int b = 20; 9 | int c = a + b; 10 | 11 | System.out.println(c); 12 | 13 | } 14 | } 15 | 16 | // 17 | 18 | public class HelloWorld{ 19 | 20 | public static void main(String []args){ 21 | 22 | double a = 10; 23 | double b = 20; 24 | double c = a + b; 25 | 26 | System.out.println(c); 27 | 28 | String s = "Hello World"; 29 | 30 | System.out.println(s); 31 | 32 | } 33 | } 34 | 35 | // 36 | 37 | public class HelloWorld{ 38 | 39 | public static void main(String []args){ 40 | 41 | boolean b = true; 42 | 43 | System.out.println(b); 44 | 45 | } 46 | } 47 | 48 | // С некоторого момента прошло 234 дня. Сколько полных недель прошло за этот период? А месяцев? 49 | 50 | public class HelloWorld{ 51 | 52 | public static void main(String []args){ 53 | 54 | int days = 234; 55 | 56 | int weeks = days / 7; 57 | 58 | int months = days / 30; 59 | 60 | System.out.println("Weeks = " + weeks); 61 | System.out.println("Months = " + months); 62 | 63 | } 64 | } 65 | 66 | /* 67 | Дано двузначное число 39. Найти: 68 | число десятков в нем; 69 | число единиц в нем; 70 | сумму его цифр; 71 | произведение его цифр. 72 | */ 73 | 74 | public class HelloWorld{ 75 | 76 | public static void main(String []args){ 77 | 78 | int number = 39; 79 | 80 | int d = number / 10; 81 | int e = number % 10; 82 | 83 | System.out.println(d); 84 | System.out.println(e); 85 | 86 | } 87 | } 88 | 89 | // Разложение трехзначного числа 90 | 91 | public class HelloWorld{ 92 | 93 | public static void main(String []args){ 94 | 95 | int number = 456; 96 | 97 | int s = number / 100; 98 | int d = number % 100 / 10; 99 | int e = number % 10; 100 | 101 | System.out.println(s); 102 | System.out.println(d); 103 | System.out.println(e); 104 | 105 | } 106 | } 107 | 108 | // Нахождение квадратного корня 109 | 110 | public class HelloWorld{ 111 | 112 | public static void main(String []args){ 113 | 114 | int d = 16; 115 | 116 | double sqrt = Math.sqrt(d); 117 | 118 | System.out.println(sqrt); 119 | 120 | } 121 | } 122 | 123 | // 124 | 125 | public class HelloWorld{ 126 | 127 | public static void main(String []args){ 128 | 129 | int a = 10; 130 | int b = 10; 131 | 132 | boolean c = (a > b); 133 | 134 | System.out.println(c); 135 | 136 | } 137 | } 138 | 139 | // 140 | 141 | public class HelloWorld{ 142 | 143 | public static void main(String []args){ 144 | 145 | int a = 100; 146 | int b = 20; 147 | 148 | if(a > b) 149 | { 150 | System.out.println("a is bigger"); 151 | } 152 | else 153 | { 154 | System.out.println("b is bigger"); 155 | } 156 | 157 | } 158 | } 159 | 160 | // 161 | 162 | public class HelloWorld{ 163 | 164 | public static void main(String []args){ 165 | 166 | int a = 100; 167 | int b = 100; 168 | 169 | if(b > a) 170 | { 171 | System.out.println("Mnogo"); 172 | } 173 | else 174 | if(b < a) 175 | { 176 | System.out.println("Malo"); 177 | } 178 | else 179 | { 180 | System.out.println("Ugadali"); 181 | } 182 | } 183 | } 184 | 185 | // Составить программу, которая уменьшает первое введенное число в два раза, если оно больше второго введенного числа по абсолютной величине. 186 | 187 | public class HelloWorld{ 188 | 189 | public static void main(String []args){ 190 | 191 | int a = -30; 192 | int b = -40; 193 | 194 | if(Math.abs(a) > Math.abs(b)) 195 | { 196 | a = a / 2; 197 | } 198 | 199 | System.out.println(a); 200 | } 201 | } -------------------------------------------------------------------------------- /Topic 1.1.3.java: -------------------------------------------------------------------------------- 1 | // 2 | 3 | public class HelloWorld{ 4 | 5 | public static void main(String []args){ 6 | 7 | 8 | for(int i = 1; i <= 5; i++) 9 | { 10 | System.out.println("Hello World"); 11 | } 12 | 13 | } 14 | } 15 | 16 | // 17 | 18 | public class HelloWorld{ 19 | 20 | public static void main(String []args){ 21 | 22 | 23 | for(int i = 1; i <= 10; i = i * 2) 24 | { 25 | System.out.println(i); 26 | } 27 | 28 | } 29 | } 30 | 31 | /* 32 | Напечатать числа следующим образом: 33 | 10 10.4 34 | 11 11.4 35 | ... 36 | 25 25.4 37 | 38 | */ 39 | 40 | public class HelloWorld{ 41 | 42 | public static void main(String []args){ 43 | 44 | for(int i = 10; i <= 25; i++) 45 | { 46 | System.out.println(i + " " + i + ".4"); 47 | } 48 | } 49 | } 50 | 51 | /* 52 | Напечатать таблицу умножения на 7: 53 | 1 х 7 = 7 54 | 2 х 7 = 14 55 | ... 56 | 9 х 7 = 63 57 | */ 58 | 59 | public class HelloWorld{ 60 | 61 | public static void main(String []args){ 62 | 63 | for(int i = 1; i <= 9; i++) 64 | { 65 | System.out.println(i + " x 7 = " + i*7); 66 | } 67 | } 68 | } 69 | 70 | /* 71 | Найти: 72 | - сумму всех целых чисел от 100 до 500; 73 | - сумму всех целых чисел от a до b (значения a и b вводятся с клавиатуры; b>=a). 74 | */ 75 | 76 | public class HelloWorld{ 77 | 78 | public static void main(String []args){ 79 | 80 | int sum = 0; 81 | 82 | for(int i = 100; i <= 500; i++) 83 | { 84 | System.out.println("---------------"); 85 | System.out.println("i = " + i); 86 | System.out.println("old sum = " + sum); 87 | sum = sum + i; 88 | System.out.println("new sum = " + sum); 89 | System.out.println("---------------"); 90 | System.out.println(); 91 | } 92 | 93 | System.out.println(sum); 94 | 95 | } 96 | } 97 | 98 | public class HelloWorld{ 99 | 100 | public static void main(String []args){ 101 | 102 | int a = 55; 103 | int b = 70; 104 | 105 | int sum = 0; 106 | 107 | if(a > b) 108 | System.out.println("Incorrect data"); 109 | else 110 | { 111 | for(int i = a; i <= b; i++) 112 | { 113 | sum = sum + i; 114 | } 115 | 116 | System.out.println(sum); 117 | 118 | } 119 | 120 | } 121 | } 122 | 123 | // while; do while 124 | 125 | public class HelloWorld{ 126 | 127 | public static void main(String []args){ 128 | 129 | int i = 10; 130 | 131 | while(i < 20) 132 | { 133 | System.out.println(i); 134 | i++; 135 | } 136 | } 137 | } 138 | 139 | public class HelloWorld{ 140 | 141 | public static void main(String []args){ 142 | 143 | int i = 10; 144 | 145 | do 146 | { 147 | System.out.println(i); 148 | i++; 149 | } 150 | 151 | while(i > 20); 152 | 153 | } 154 | } 155 | 156 | // Найти максимальное из натуральных чисел, не превышающих 5000, которое нацело делится на 39. 157 | 158 | public class HelloWorld{ 159 | 160 | public static void main(String []args){ 161 | 162 | for(int i = 5000; i > 0; i--) 163 | { 164 | if(i % 39 == 0) 165 | { 166 | System.out.println(i); 167 | break; 168 | } 169 | } 170 | } 171 | } 172 | 173 | /* 174 | Гражданин 1 марта открыл счет в банке, вложив 1000 руб. 175 | Через каждый месяц размер вклада увеличивается на 2% от имеющейся суммы. 176 | Определить: 177 | - за какой месяц величина ежемесячного увеличения вклада превысит 30 руб.; 178 | */ 179 | 180 | public class HelloWorld{ 181 | 182 | public static void main(String []args){ 183 | 184 | double account = 1000; 185 | 186 | for(int i = 1; i <= 36; i++) 187 | { 188 | if(account * 0.02 >= 30) 189 | { 190 | System.out.println("Month = " + i); 191 | break; 192 | } 193 | else 194 | { 195 | account = account + account * 0.02; 196 | } 197 | } 198 | } 199 | } 200 | 201 | -------------------------------------------------------------------------------- /Topic 1.1.4.java: -------------------------------------------------------------------------------- 1 | // 2 | 3 | public class HelloWorld{ 4 | 5 | public static int Max(int a, int b) 6 | { 7 | int max; 8 | 9 | if(a > b) 10 | max = a; 11 | else 12 | max = b; 13 | 14 | return max; 15 | } 16 | 17 | public static void main(String []args){ 18 | 19 | int a = 11; 20 | int b = 33; 21 | 22 | int x = -24; 23 | int y = 145; 24 | 25 | int max1 = Max(a, b); 26 | int max2 = Max(x, y); 27 | 28 | System.out.println(max1); 29 | System.out.println(max2); 30 | } 31 | } 32 | 33 | /* 34 | Напечатать числа в виде следующей таблицы: 35 | 5 5 5 5 5 5 36 | 5 5 5 5 5 5 37 | 5 5 5 5 5 5 38 | 5 5 5 5 5 5 39 | */ 40 | 41 | public class HelloWorld{ 42 | 43 | public static void Print() 44 | { 45 | for(int i = 1; i <= 4; i++) 46 | { 47 | System.out.println("5 5 5 5 5 5"); 48 | } 49 | } 50 | 51 | public static void main(String []args){ 52 | 53 | Print(); 54 | 55 | } 56 | } 57 | 58 | // Напечатать таблицу сложения 59 | 60 | public class HelloWorld{ 61 | 62 | public static void printElement(int i, int j) 63 | { 64 | System.out.print(i + " + " + j + " = " + (i + j) + "\t"); 65 | } 66 | 67 | public static void printLine(int i) 68 | { 69 | for(int j = 1; j <= 9; j++) 70 | { 71 | printElement(i,j); 72 | } 73 | System.out.println(); 74 | } 75 | 76 | public static void printTable() 77 | { 78 | for(int i = 1; i <= 9; i++) 79 | { 80 | printLine(i); 81 | } 82 | } 83 | 84 | public static void main(String []args){ 85 | 86 | printTable(); 87 | 88 | } 89 | } 90 | 91 | /* 92 | Реализовать функцию нахождения максимума: 93 | Из трёх чисел 94 | Из четырёх чисел 95 | */ 96 | 97 | public class HelloWorld{ 98 | 99 | public static int maxOfTwo(int a, int b) 100 | { 101 | int max; 102 | 103 | if(a > b) 104 | max = a; 105 | else 106 | max = b; 107 | 108 | return max; 109 | } 110 | 111 | public static int maxOfThree(int a, int b, int c) 112 | { 113 | return maxOfTwo(maxOfTwo(a,b), c); 114 | } 115 | 116 | public static int maxOfFour(int a, int b, int c, int d) 117 | { 118 | return maxOfTwo(maxOfTwo(a,b),maxOfTwo(c,d)); 119 | } 120 | 121 | public static void main(String []args){ 122 | 123 | System.out.println(maxOfFour(1, 3, 5 ,9)); 124 | System.out.println(maxOfFour(-1, -3, -5 ,-9)); 125 | System.out.println(maxOfFour(0, 24 , 15 , 12)); 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /Topic 1.1.5.java: -------------------------------------------------------------------------------- 1 | // Треугольник 2 | 3 | public class HelloWorld{ 4 | 5 | public static double perimetr(double a, double b, double c) 6 | { 7 | if(isTriangle(a, b, c) == true) 8 | return a + b + c; 9 | else 10 | return 0; 11 | } 12 | 13 | public static double square(double a, double b, double c) 14 | { 15 | double p = perimetr(a, b, c) / 2; 16 | 17 | double s = Math.sqrt(p*(p-a)*(p-b)*(p-c)); 18 | 19 | return s; 20 | } 21 | 22 | public static boolean isTriangle(double a, double b, double c) 23 | { 24 | boolean isTriangle; 25 | 26 | if((a > 0) && (b > 0) && (c > 0) && (a + b > c) && (a + c > b) && (b + c > a)) 27 | isTriangle = true; 28 | else 29 | isTriangle = false; 30 | 31 | return isTriangle; 32 | } 33 | 34 | public static void main(String []args){ 35 | 36 | System.out.println(square(-2,-2,7)); 37 | } 38 | } 39 | 40 | 41 | // https://codeboard.io/projects/247526 42 | 43 | // https://codeboard.io/projects/291528 44 | 45 | -------------------------------------------------------------------------------- /Topic 1.1.6.java: -------------------------------------------------------------------------------- 1 | // 2 | 3 | public class HelloWorld{ 4 | 5 | public static void main(String []args){ 6 | 7 | int[] numbers = new int[5]; 8 | 9 | numbers[0] = 5; 10 | numbers[3] = 7; 11 | 12 | for(int i = 0; i < numbers.length; i++) 13 | { 14 | System.out.print(numbers[i] + " "); 15 | } 16 | 17 | } 18 | } 19 | 20 | // 21 | 22 | import java.util.Random; 23 | 24 | public class HelloWorld{ 25 | 26 | public static void printArray(int[] array) 27 | { 28 | for(int i = 0; i < array.length; i++) 29 | { 30 | System.out.print(array[i] + " "); 31 | } 32 | } 33 | 34 | public static int[] generateArray(int n) 35 | { 36 | int[] array = new int[n]; 37 | 38 | Random r = new Random(); 39 | 40 | for(int j = 0; j < array.length; j++) 41 | { 42 | array[j] = r.nextInt(100); 43 | } 44 | 45 | return array; 46 | } 47 | 48 | public static void main(String []args){ 49 | 50 | printArray(generateArray(10)); 51 | 52 | } 53 | } 54 | 55 | /* 56 | Дан массив. Все его элементы: 57 | увеличить в 2 раза 58 | уменьшить на число А 59 | разделить на первый элемент 60 | */ 61 | 62 | import java.util.Random; 63 | 64 | public class HelloWorld{ 65 | 66 | public static void printArray(double[] array) 67 | { 68 | for(int i = 0; i < array.length; i++) 69 | { 70 | System.out.print(array[i] + "\t"); 71 | } 72 | System.out.println(); 73 | } 74 | 75 | public static double[] generateArray(int n) 76 | { 77 | double[] array = new double[n]; 78 | 79 | Random r = new Random(); 80 | 81 | for(int j = 0; j < array.length; j++) 82 | { 83 | array[j] = r.nextInt(100); 84 | } 85 | 86 | return array; 87 | } 88 | 89 | public static double[] multiplyByTwo(double[] array) 90 | { 91 | for(int i = 0; i < array.length; i++) 92 | { 93 | array[i] = array[i] * 2; 94 | } 95 | 96 | return array; 97 | } 98 | 99 | public static double[] decreaseByA(double[] array, double a) 100 | { 101 | for(int i = 0; i < array.length; i++) 102 | { 103 | array[i] = array[i] - a; 104 | } 105 | 106 | return array; 107 | } 108 | 109 | public static double[] divideByFirstElement(double[] array) 110 | { 111 | double x = array[0]; 112 | 113 | for(int i = 0; i < array.length; i++) 114 | { 115 | array[i] = array[i] / x; 116 | } 117 | 118 | return array; 119 | } 120 | 121 | public static void main(String []args){ 122 | 123 | double[] array = generateArray(5); 124 | 125 | printArray(array); 126 | printArray(multiplyByTwo(array)); 127 | printArray(decreaseByA(array, 20.0)); 128 | printArray(divideByFirstElement(array)); 129 | 130 | 131 | } 132 | } 133 | 134 | /* 135 | Дан массив. Напечатать все неотрицательные элементы 136 | */ 137 | 138 | import java.util.Random; 139 | 140 | public class HelloWorld{ 141 | 142 | public static void printArray(double[] array) 143 | { 144 | for(int i = 0; i < array.length; i++) 145 | { 146 | System.out.print(array[i] + " "); 147 | } 148 | System.out.println(); 149 | } 150 | 151 | public static void printNonNegativeElements(double[] array) 152 | { 153 | for(int i = 0; i < array.length; i++) 154 | { 155 | if(array[i] >= 0) 156 | { 157 | System.out.print(array[i] + " "); 158 | } 159 | } 160 | System.out.println(); 161 | } 162 | 163 | public static void main(String []args){ 164 | 165 | double[] array = {1, 3, 5, -2, 0, 10, -5, 14, 10}; 166 | 167 | printArray(array); 168 | printNonNegativeElements(array); 169 | 170 | } 171 | } 172 | 173 | /* 174 | Дан массив. Определить: 175 | максимальный элемент 176 | минимальный элемент 177 | на сколько максимальный элемент больше минимального 178 | индекс максимального элемента 179 | индекс минимального элемента 180 | */ 181 | 182 | import java.util.Random; 183 | 184 | public class HelloWorld{ 185 | 186 | public static void printArray(double[] array) 187 | { 188 | for(int i = 0; i < array.length; i++) 189 | { 190 | System.out.print(array[i] + " "); 191 | } 192 | System.out.println(); 193 | } 194 | 195 | public static double[] generateArray(int n) 196 | { 197 | double[] array = new double[n]; 198 | 199 | Random r = new Random(); 200 | 201 | for(int j = 0; j < array.length; j++) 202 | { 203 | array[j] = r.nextInt(100); 204 | } 205 | 206 | return array; 207 | } 208 | 209 | public static double findMaxElement(double[] array) 210 | { 211 | double max = array[0]; 212 | 213 | for(int i = 1; i < array.length; i++) 214 | { 215 | if(array[i] > max) 216 | { 217 | max = array[i]; 218 | } 219 | } 220 | 221 | return max; 222 | } 223 | 224 | public static double findMinElement(double[] array) 225 | { 226 | double min = array[0]; 227 | 228 | for(int i = 1; i < array.length; i++) 229 | { 230 | if(array[i] < min) 231 | { 232 | min = array[i]; 233 | } 234 | } 235 | 236 | return min; 237 | } 238 | 239 | public static int findIndexOfMaxElement(double[] array) 240 | { 241 | int index = 0; 242 | 243 | double max = findMaxElement(array); 244 | 245 | for(int i = 0; i < array.length; i++) 246 | { 247 | if(array[i] == max) 248 | { 249 | index = i; 250 | break; 251 | } 252 | } 253 | 254 | return index; 255 | } 256 | 257 | public static int findIndexOfMinElement(double[] array) 258 | { 259 | int index = 0; 260 | 261 | double min = findMinElement(array); 262 | 263 | for(int i = 0; i < array.length; i++) 264 | { 265 | if(array[i] == min) 266 | { 267 | index = i; 268 | break; 269 | } 270 | } 271 | 272 | return index; 273 | } 274 | 275 | 276 | public static void main(String []args){ 277 | 278 | double[] array = generateArray(10); 279 | printArray(array); 280 | 281 | System.out.println("Max element = " + findMaxElement(array) + " with index = " + findIndexOfMaxElement(array)); 282 | 283 | System.out.println("Min element = " + findMinElement(array) + " with index = " + findIndexOfMinElement(array)); 284 | 285 | 286 | 287 | } 288 | } 289 | 290 | /* 291 | Дан массив. Поменять местами второй и пятый элементы; 292 | */ 293 | 294 | import java.util.Random; 295 | 296 | public class HelloWorld{ 297 | 298 | public static void printArray(double[] array) 299 | { 300 | for(int i = 0; i < array.length; i++) 301 | { 302 | System.out.print(array[i] + " "); 303 | } 304 | System.out.println(); 305 | } 306 | 307 | public static double[] generateArray(int n) 308 | { 309 | double[] array = new double[n]; 310 | 311 | Random r = new Random(); 312 | 313 | for(int j = 0; j < array.length; j++) 314 | { 315 | array[j] = r.nextInt(100); 316 | } 317 | 318 | return array; 319 | } 320 | 321 | public static double findMaxElement(double[] array) 322 | { 323 | double max = array[0]; 324 | 325 | for(int i = 1; i < array.length; i++) 326 | { 327 | if(array[i] > max) 328 | { 329 | max = array[i]; 330 | } 331 | } 332 | 333 | return max; 334 | } 335 | 336 | public static double findMinElement(double[] array) 337 | { 338 | double min = array[0]; 339 | 340 | for(int i = 1; i < array.length; i++) 341 | { 342 | if(array[i] < min) 343 | { 344 | min = array[i]; 345 | } 346 | } 347 | 348 | return min; 349 | } 350 | 351 | public static int findIndexOfMaxElement(double[] array) 352 | { 353 | int index = 0; 354 | 355 | double max = findMaxElement(array); 356 | 357 | for(int i = 0; i < array.length; i++) 358 | { 359 | if(array[i] == max) 360 | { 361 | index = i; 362 | break; 363 | } 364 | } 365 | 366 | return index; 367 | } 368 | 369 | public static int findIndexOfMinElement(double[] array) 370 | { 371 | int index = 0; 372 | 373 | double min = findMinElement(array); 374 | 375 | for(int i = 0; i < array.length; i++) 376 | { 377 | if(array[i] == min) 378 | { 379 | index = i; 380 | break; 381 | } 382 | } 383 | 384 | return index; 385 | } 386 | 387 | public static double[] swapElements(double[] array, int n, int m) 388 | { 389 | if((n < array.length) && (m < array.length) && (n >= 0) && (m >= 0)) 390 | { 391 | double temp = array[n]; 392 | array[n] = array[m]; 393 | array[m] = temp; 394 | 395 | return array; 396 | } 397 | else 398 | { 399 | return array; 400 | } 401 | } 402 | 403 | public static void main(String []args){ 404 | 405 | double[] array = generateArray(10); 406 | printArray(array); 407 | 408 | printArray(swapElements(array, 1, 7)); 409 | 410 | } 411 | } -------------------------------------------------------------------------------- /Topic 1.1.7.java: -------------------------------------------------------------------------------- 1 | // Ссылка на проект с очередью: https://codeboard.io/projects/294054 2 | 3 | // Работа с arrayList 4 | 5 | import java.util.ArrayList; 6 | 7 | public class HelloWorld{ 8 | 9 | public static void printArrayList(ArrayList arrayList) 10 | { 11 | for(int i = 0; i < arrayList.size(); i++) 12 | { 13 | String value = arrayList.get(i); 14 | System.out.print(value + " "); 15 | } 16 | System.out.println(); 17 | } 18 | 19 | public static void printArraySize(ArrayList arrayList) 20 | { 21 | System.out.println("Size of the arrayList is " + arrayList.size()); 22 | } 23 | 24 | public static void main(String []args){ 25 | 26 | ArrayList arrayList = new ArrayList<>(); 27 | 28 | printArrayList(arrayList); 29 | arrayList.add("Anton"); 30 | printArrayList(arrayList); 31 | arrayList.add("Mikhail"); 32 | printArrayList(arrayList); 33 | arrayList.add("Anna"); 34 | printArrayList(arrayList); 35 | arrayList.add("Mikhail"); 36 | printArrayList(arrayList); 37 | 38 | arrayList.add(0,"Kate"); 39 | printArrayList(arrayList); 40 | 41 | arrayList.add(2,"Daria"); 42 | printArrayList(arrayList); 43 | 44 | arrayList.remove(0); 45 | printArrayList(arrayList); 46 | 47 | arrayList.remove("Mikhail"); 48 | printArrayList(arrayList); 49 | 50 | arrayList.remove("Mikhail"); 51 | printArrayList(arrayList); 52 | } 53 | } 54 | 55 | // Ссылка на работу с arrayList и linkedList: https://javarush.ru/groups/posts/dinamicheskie-massivy-java -------------------------------------------------------------------------------- /Topic 1.1.8.java: -------------------------------------------------------------------------------- 1 | // 2 | public class HelloWorld{ 3 | 4 | public static void main(String []args){ 5 | 6 | int[] array = new int[5]; 7 | 8 | try 9 | { 10 | array[0] = 4; 11 | array[2] = 10; 12 | array[3] = 6; 13 | array[5] = 4; 14 | } 15 | 16 | catch(Exception e) 17 | { 18 | System.out.println("There is the Exception!"); 19 | } 20 | 21 | finally 22 | { 23 | System.out.println("This is the finally area!"); 24 | } 25 | 26 | System.out.println("The End"); 27 | 28 | } 29 | } 30 | 31 | // https://javarush.ru/groups/posts/1944-iskljuchenija-checked-unchecked-i-svoi-sobstvennihe 32 | 33 | public class HelloWorld{ 34 | 35 | public static void main(String []args){ 36 | 37 | int[] array = new int[5]; 38 | 39 | try 40 | { 41 | array[0] = 4; 42 | array[2] = 10; 43 | array[3] = 6; 44 | array[5] = 10; 45 | 46 | int a = 10; 47 | int b = a / 0; 48 | } 49 | 50 | catch(ArrayIndexOutOfBoundsException ex) 51 | { 52 | System.out.println("ArrayIndexOutOfBoundsException!"); 53 | } 54 | 55 | catch(ArithmeticException exc) 56 | { 57 | System.out.println("ArithmeticException!"); 58 | } 59 | 60 | catch(Exception e) 61 | { 62 | System.out.println("Exception!"); 63 | } 64 | 65 | 66 | finally 67 | { 68 | System.out.println("This is the finally area!"); 69 | } 70 | 71 | System.out.println("The End"); 72 | 73 | } 74 | } 75 | 76 | // StackTrace 77 | 78 | public class HelloWorld{ 79 | 80 | public static void main(String []args){ 81 | 82 | int[] array = new int[5]; 83 | 84 | try 85 | { 86 | array[0] = 4; 87 | array[2] = 10; 88 | array[3] = 6; 89 | array[5] = 10; 90 | } 91 | 92 | catch(Exception e) 93 | { 94 | e.printStackTrace(); 95 | } 96 | 97 | 98 | finally 99 | { 100 | System.out.println("This is the finally area!"); 101 | } 102 | 103 | System.out.println("The End"); 104 | 105 | } 106 | } 107 | 108 | // https://codeboard.io/projects/295050 - базовый проект для Unit-тестов 109 | 110 | // https://codeboard.io/projects/295066 - основной проект для Unit-тестов 111 | -------------------------------------------------------------------------------- /Topic 1.2.1.sql: -------------------------------------------------------------------------------- 1 | -- Выбор всей таблицы 2 | SELECT * FROM Phones 3 | -- 4 | SELECT manufacturer, model FROM Phones 5 | -- Отсортировать по цене 6 | SELECT * FROM Phones ORDER BY price DESC 7 | -- Отсортировать по цене по убыванию. Показать 5 штук 8 | SELECT * FROM Phones 9 | ORDER BY price 10 | DESC 11 | LIMIT 5 12 | -- Вывести все телефоны с ценой большей 60000 13 | SELECT * FROM Phones 14 | WHERE price > 60000 15 | -- Вывести все телефоны с ценой большей 60000 по цене по убыванию. Показать 5 штук 16 | SELECT * FROM Phones 17 | WHERE price > 60000 18 | ORDER BY price 19 | DESC 20 | LIMIT 5 21 | -- Если надо выбрать конкретно айфон 11 например за 95ооо руб 22 | SELECT * FROM Phones 23 | WHERE manufacturer = 'Apple' AND model = 'iPhone 11' AND price > 95000 24 | -- Найти телефоны в ценой от 50000 до 80000 25 | SELECT * FROM Phones 26 | WHERE price >= 50000 AND price <= 80000 27 | 28 | SELECT * FROM Phones 29 | WHERE price BETWEEN 50000 AND 80000 30 | 31 | -- Найти телефоны Apple, Xiaomi, Samsung 32 | SELECT * FROM Phones 33 | WHERE manufacturer = 'Apple' OR manufacturer = 'Samsung' OR manufacturer = 'Xiaomi' 34 | 35 | SELECT * FROM Phones 36 | WHERE manufacturer IN ('Apple', 'Xiaomi', 'Samsung') 37 | 38 | -- Найти телефоны кроме Apple, Xiaomi, Samsung 39 | SELECT * FROM Phones 40 | WHERE manufacturer NOT IN ('Apple', 'Xiaomi', 'Samsung') 41 | 42 | SELECT * FROM Phones 43 | WHERE manufacturer != 'Apple' AND manufacturer != 'Samsung' AND manufacturer != 'Xiaomi' 44 | -------------------------------------------------------------------------------- /Topic 1.2.2.sql: -------------------------------------------------------------------------------- 1 | -- Использование агрегатных функций 2 | SELECT MAX(price) FROM phones 3 | SELECT MIN(price) FROM phones 4 | SELECT AVG(price) FROM phones 5 | SELECT SUM(price) FROM phones 6 | SELECT COUNT(price) FROM phones 7 | 8 | -- Найти информацию о телефоне с максимальной ценой 9 | SELECT * FROM phones 10 | ORDER BY price 11 | DESC 12 | LIMIT 1 13 | 14 | 15 | SELECT * FROM phones WHERE price = (SELECT MAX(price) FROM phones) 16 | 17 | -- Найти телефоны с ценой выше средней 18 | SELECT * FROM phones WHERE price > (SELECT AVG(price) FROM phones) 19 | 20 | -- Вывести настоящую среднюю цену для всех телефонов 21 | SELECT *, price*quantity AS Total FROM phones 22 | SELECT SUM(price*quantity)/SUM(quantity) FROM phones 23 | 24 | -- Найти количество производителей телефонов 25 | SELECT DISTINCT(manufacturer) FROM phones 26 | SELECT COUNT(DISTINCT(manufacturer)) FROM phones 27 | 28 | -- Найти среднюю цену телефонов по производителям 29 | SELECT manufacturer, ROUND(AVG(price), 2) FROM phones 30 | GROUP BY manufacturer 31 | 32 | -- Вывести модели и их количество 33 | SELECT model, manufacturer, SUM(quantity) FROM phones 34 | GROUP BY model, manufacturer 35 | 36 | -- Найти среднюю цену телефонов по производителям со средней ценой большей 60000 37 | SELECT manufacturer, ROUND(AVG(price), 2) FROM phones 38 | GROUP BY manufacturer 39 | HAVING AVG(price) > 60000 40 | 41 | -- Вывести всю информацию обо всех товарах 42 | SELECT * FROM products 43 | JOIN prices ON prices.product_id = products.id 44 | JOIN manufacturers ON manufacturers.id = products.manufacturer_id 45 | 46 | SELECT products.id, products.name, prices.value, manufacturers.name, manufacturers.location FROM products 47 | JOIN prices ON prices.product_id = products.id 48 | JOIN manufacturers ON manufacturers.id = products.manufacturer_id 49 | 50 | SELECT p.id, p.name, pr.value, m.name, m.location FROM products p 51 | JOIN prices pr ON pr.product_id = p.id 52 | JOIN manufacturers m ON m.id = p.manufacturer_id 53 | 54 | -- Вывести всю информацию обо всех товарах производителей из Москвы 55 | SELECT p.id, p.name, pr.value, m.name, m.location FROM products p 56 | JOIN prices pr ON pr.product_id = p.id 57 | JOIN manufacturers m ON m.id = p.manufacturer_id 58 | WHERE m.location = 'Moscow' 59 | 60 | SELECT p.id, p.name, pr.value, m.name, m.location FROM products p 61 | JOIN prices pr ON pr.product_id = p.id 62 | JOIN manufacturers m ON m.id = p.manufacturer_id AND m.location = 'Moscow' 63 | 64 | -- LEFT/RIGHT/INNER JOIN 65 | SELECT p.id, p.name, pr.value FROM products p 66 | INNER JOIN prices pr ON pr.product_id = p.id 67 | 68 | SELECT p.id, p.name, pr.value FROM products p 69 | LEFT JOIN prices pr ON pr.product_id = p.id 70 | 71 | SELECT products.id, products.name, prices.value FROM prices 72 | RIGHT JOIN products ON prices.product_id = products.id 73 | 74 | -- Вывести производетелей товаров, количество их товаров на рынке и среднюю цену 75 | SELECT manufacturers.name, COUNT(products.id), ROUND(AVG(prices.value),2) FROM products 76 | JOIN prices ON prices.product_id = products.id 77 | JOIN manufacturers ON manufacturers.id = products.manufacturer_id 78 | GROUP BY manufacturers.name 79 | ORDER BY AVG(prices.value) 80 | DESC -------------------------------------------------------------------------------- /Topic 1.2.3.sql: -------------------------------------------------------------------------------- 1 | -- Вывод максимальной цены 2 | 3 | CREATE DEFINER=`root`@`localhost` PROCEDURE `show_max_price`() 4 | BEGIN 5 | SELECT MAX(price) from testdb.phones; 6 | END 7 | 8 | -- Вывод телефонов в ценовом диапазоне 9 | 10 | CREATE DEFINER=`root`@`localhost` PROCEDURE `find_the_phones_in_range`(IN first_price int, IN second_price int) 11 | BEGIN 12 | IF first_price >= second_price 13 | THEN 14 | SELECT * FROM testdb.phones WHERE price BETWEEN second_price AND first_price; 15 | ELSE 16 | SELECT * FROM testdb.phones WHERE price BETWEEN first_price AND second_price; 17 | END IF; 18 | END 19 | 20 | -- Добавление нового телефона 21 | 22 | CREATE DEFINER=`root`@`localhost` PROCEDURE `add_phone`(IN id int, IN model VARCHAR(50), IN manufacturer VARCHAR(50), IN quantity INT, IN price int) 23 | BEGIN 24 | INSERT INTO `testdb`.`phones` (`id`, `model`, `manufacturer`, `quantity`, `price`) VALUES (id, model, manufacturer, quantity, price); 25 | END 26 | 27 | -- Получение максимального значения id из таблицы 28 | 29 | CREATE FUNCTION `get_max_id` () 30 | RETURNS INTEGER 31 | DETERMINISTIC 32 | BEGIN 33 | DECLARE idx int; 34 | SELECT MAX(id) INTO idx from testdb.phones; 35 | RETURN idx; 36 | END 37 | 38 | -- Добавление нового телефона без id 39 | 40 | CREATE DEFINER=`root`@`localhost` PROCEDURE `add_phone_without_id`(IN model VARCHAR(50), IN manufacturer VARCHAR(50), IN quantity INT, IN price int) 41 | BEGIN 42 | DECLARE id int; 43 | SET id = testdb.get_max_id() + 1; 44 | INSERT INTO `testdb`.`phones` (`id`, `model`, `manufacturer`, `quantity`, `price`) VALUES (id, model, manufacturer, quantity, price); 45 | END 46 | 47 | -- Изменение цен 48 | 49 | CREATE DEFINER=`root`@`localhost` PROCEDURE `update_prices`() 50 | BEGIN 51 | UPDATE testdb.phones 52 | SET price = price - 2000 53 | WHERE quantity > 0 AND quantity <= 3; 54 | END 55 | -------------------------------------------------------------------------------- /URLs: -------------------------------------------------------------------------------- 1 | Ссылки на рабочие инструменты 2 | 3 | Работа с кодом: 4 | https://www.tutorialspoint.com/codingground.htm 5 | https://codeboard.io/ 6 | 7 | Работа с базами данных: 8 | Онлайн вариант: https://www.elephantsql.com/ 9 | Онлайн вариант: https://www.db-fiddle.com/ 10 | Оффлайн работа: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 11 | 12 | 13 | 14 | 15 | 16 | Ссылки на полезные статьи 17 | 18 | Методологии и модели разработки ПО: 19 | AGILE-манифест: https://agilemanifesto.org/iso/ru/manifesto.html 20 | SCRUM-гайд 2020: https://scrumguides.org/docs/scrumguide/v2020/2020-Scrum-Guide-Russian.pdf 21 | Статьи от Atlassian: https://www.atlassian.com/ru/agile 22 | Sbergile: https://hr-academy.ru/hrarticle/agile-transformatsiya-v-sberbanke.html 23 | --------------------------------------------------------------------------------