Created
December 6, 2016 17:39
-
-
Save JonathanParser/f4ecf341c342affcec2bde902a1a14df to your computer and use it in GitHub Desktop.
Geegbrain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package JavaGeegbrain; | |
/** | |
* Created by Jack Sparrow on 02.12.2016. | |
*/ | |
public class Lesson1 { | |
public static void main (String[] args){ | |
byte x = 127; | |
short y = 32767; | |
int z = 2147483647; | |
long q = 15000L; | |
char w = 12; | |
float e = 120.0f; | |
boolean r = true; | |
double t = 15.72d; | |
int a = 10; | |
int b = 15; | |
int c = 155; | |
int d = 18; | |
int howyear = 2016; | |
System.out.println("Обьевили переменые всех пройденых типов"); | |
System.out.println("Вызываем метод summa и получаем результат "+summa(a,b,c,d)); | |
System.out.println("Вызываем метод check результат "+check(a,b)); | |
checgod(howyear); | |
} | |
public static int summa(int a, int b, int c, int d){ | |
return a*(b+( c / d)); | |
} | |
public static boolean check(int a, int b){ | |
if (a+b>=10 && a+b<=20) | |
return true; | |
else | |
return false; | |
} | |
public static void checgod (int howyear){ | |
if ((howyear % 4 == 0 && howyear % 100 != 0) || howyear % 400 == 0) | |
System.out.println("Год "+howyear+ " Високосный "); | |
else | |
System.out.println("Год " + howyear + " НЕвисокосный "); | |
} | |
/** | |
* Created by Jack Sparrow on 06.12.2016. | |
*/ | |
public static class Lesson2 { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package JavaGeegbrain; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
/** | |
* Created by Jack Sparrow on 06.12.2016. | |
*/ | |
public class Lesson2 { | |
public static void main(String[] args) { | |
int[] a = { 1, 1, 0, 0, 1, 0, 1, 1, 0, 0 }; //Задание №1 | |
change(a);// Задание №2 | |
int[] b = new int[8]; // Задание №3 | |
arreyadd(b); // | |
int[] mas = { 1, 5, 3, 2, 11, 4, 5, 2, 4, 8, 9, 1 }; | |
masum(mas); // Задание №4 | |
minmax(mas); //Задание №5 | |
calc(); // Задание №6 | |
} | |
private static void calc() { | |
int work = 0; | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Привет я примитивный калькулятор \nВведите первое число:"); | |
int a = sc.nextInt(); | |
System.out.println("Введите второе число:"); | |
int c = sc.nextInt(); | |
System.out.println("Введите операцию: \n+ сложить\n- вычесть\n* умножить \n/ разделить"); | |
String b = sc.next(); | |
switch (b){ | |
case "+":work = a+c; break; | |
case "-":work = a-c; break; | |
case "*":work = a*c; break; | |
case "/":work = a/c; break; | |
} | |
System.out.println("Результат: "+a+" "+b+" "+c+" = "+work); | |
} | |
private static void minmax(int[] a) { | |
int start = a[0]; | |
for (int i = 0; i <a.length ; i++) { | |
if (a[i] > start){start = a[i]; | |
} | |
} | |
System.out.println("Максимальное значение из массива Результат: "+ start); | |
for (int i = 0; i < a.length; i++) { | |
if (a[i] < start){start= a[i]; | |
} | |
} | |
System.out.println("Максимальное значение из массива Результат: "+ start); | |
} | |
private static void masum(int[] a) { | |
String c = Arrays.toString(a); | |
for (int i = 0; i < a.length; i++) { | |
if (a[i] < 6){ a[i] = a[i]*2;} | |
} | |
System.out.println("Если значение масива " +c+ " меньше 6 то умножаем на 2 \nРезультат: " +Arrays.toString(a)); | |
} | |
private static void arreyadd(int[] a) { | |
int[] c = {1, 4, 7, 10, 13, 16, 19, 22}; | |
for (int i = 0; i < c.length; i++) { | |
a[i] = c[i]; | |
} | |
System.out.println("Создали и заполнили массив "+Arrays.toString(a)); | |
} | |
private static void change(int[] a) { | |
System.out.println("Начальный массив "+Arrays.toString(a)); | |
for (int i = 0; i < a.length; i++) { | |
if (a[i] ==1){a[i]=0;} | |
else a[i]=1; | |
} | |
System.out.println("Измененный массив "+Arrays.toString(a)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{DE+FROT}+{geethim+am=fotX-|}