|
| 1 | +package com.startjava.lesson_1.variables; |
| 2 | + |
| 3 | +public class VariablesTheme { |
| 4 | + public static void main(String[] args) { |
| 5 | + String name = "Samsung"; |
| 6 | + char sign = 'R'; |
| 7 | + int model = 428; |
| 8 | + short core = 2; |
| 9 | + long pix = 1234567890; |
| 10 | + float hardware = 127.43f; |
| 11 | + double a1 = 155435.14325436; |
| 12 | + boolean a2 = true; |
| 13 | + System.out.println("Notebook " + name + " " + model + " have a " + core + "cores, " + " pix " + pix + " good device " + a2); |
| 14 | + System.out.println(); |
| 15 | + int x = 100; |
| 16 | + int y = 200; |
| 17 | + int sale = 11; |
| 18 | + System.out.println("При скидке 11%"); |
| 19 | + System.out.println("Товар 1 стоит " + (100-(100*0.11))); |
| 20 | + System.out.println("Товар 2 стоит " + (200-(200*0.11))); |
| 21 | + System.out.println(); |
| 22 | + System.out.println(" J a v v a "); |
| 23 | + System.out.println(" J a a v v a a "); |
| 24 | + System.out.println("J J aaaaa V V aaaaa "); |
| 25 | + System.out.println(" JJ a a V a a"); |
| 26 | + System.out.println(); |
| 27 | + byte byte_1 = 127; |
| 28 | + byte byte_inc = (byte) (byte_1 + 1); |
| 29 | + byte byte_dec = (byte) (byte_1 - 1); |
| 30 | + short short_2byte = 32767; |
| 31 | + short short_inc = (short) (short_2byte + 1); |
| 32 | + short short_dec = (short) (short_2byte - 1); |
| 33 | + int int_4byte = 2147483647; |
| 34 | + int int_inc = int_4byte + 1; |
| 35 | + int int_dec = int_4byte - 1; |
| 36 | + long long_8byte = 9223372036854775807L; |
| 37 | + long long_inc = long_8byte + 1; |
| 38 | + long long_dec = long_8byte - 1; |
| 39 | + float float_4byte38 = 3.4028235f; |
| 40 | + float float_inc = float_4byte38 + 1; |
| 41 | + float float_dec = float_4byte38 - 1; |
| 42 | + double double_8byte308 = 1.7976931348623157d; |
| 43 | + double double_inc = double_8byte308 + 1; |
| 44 | + double double_dec = double_8byte308 - 1; |
| 45 | + char char_2byte = 65535; |
| 46 | + char char_inc = (char) (char_2byte + 1); |
| 47 | + char char_dec = (char) (char_2byte -1); |
| 48 | + |
| 49 | + System.out.println("max byte " + byte_1 + "; i++ = " + byte_inc + " i-- = " + byte_dec); |
| 50 | + System.out.println("max short " + short_2byte + "; i++ = " + short_inc + " i-- = " + short_dec); |
| 51 | + System.out.println("max int " + int_4byte + "; i++ = " + int_inc + " i-- = " + int_dec); |
| 52 | + System.out.println("max long " + long_8byte + "; i++ = " + long_inc + " i-- = " + long_dec); |
| 53 | + System.out.println("max float " + float_4byte38 + "; i++ = " + float_inc + " i-- = " + float_dec); |
| 54 | + System.out.println("max double " + double_8byte308 + "; i++ = " + double_inc + " i-- = " + double_dec); |
| 55 | + System.out.println("max char " + char_2byte + "; i++ = " + char_inc + " i-- = " + char_dec); |
| 56 | + System.out.println(); |
| 57 | + int firstNum = 1; |
| 58 | + int secondNum = 2; |
| 59 | + int num; |
| 60 | + System.out.println("first number is " + firstNum + ", second number is " + secondNum); |
| 61 | + num = firstNum; |
| 62 | + firstNum = secondNum; |
| 63 | + secondNum = num; |
| 64 | + System.out.println("first number is " + firstNum + ", second number is " + secondNum); |
| 65 | + System.out.println(); |
| 66 | + int one = 35; |
| 67 | + int two = 38; |
| 68 | + int three = 64; |
| 69 | + int four = 94; |
| 70 | + int five = 95; |
| 71 | + System.out.println("Symbol dec " + one + " = " + (char)(one)); |
| 72 | + System.out.println("Symbol dec " + two + " = " + (char)(two)); |
| 73 | + System.out.println("Symbol dec " + three + " = " + (char)(three)); |
| 74 | + System.out.println("Symbol dec " + four + " = " + (char)(four)); |
| 75 | + System.out.println("Symbol dec " + five + " = " + (char)(five)); |
| 76 | + System.out.println(); |
| 77 | + int k = 345; |
| 78 | + int l1 = k / 10; |
| 79 | + int l2 = k % 10; |
| 80 | + int l3 = l1 % 10; |
| 81 | + int ll = l1 / 10; |
| 82 | + int sum = ll + l3 + l2; |
| 83 | + System.out.println("sum 345 is " + sum + " = " + l2 + " + " + l3 + " + " + ll); |
| 84 | + System.out.println(); |
| 85 | + char ab = 47; |
| 86 | + char ba = 92; |
| 87 | + char la = 95; |
| 88 | + char bo = 40; |
| 89 | + |
| 90 | + System.out.println(" " + ab + ba + " "); |
| 91 | + System.out.println(" " + ab + " " + ba + " "); |
| 92 | + System.out.println(" " + ab + la + bo + " " + ((char) (bo + 1)) + ba + " "); |
| 93 | + System.out.println(" " + ab + " " + ba + " "); |
| 94 | + System.out.println(ab + "" + la + "" + la + "" + la + "" + la + "" + ab + "" + ba + "" + la + "" + la + "" + ba + " "); |
| 95 | + System.out.println(); |
| 96 | + int secund = 86399; |
| 97 | + int minute = secund / 60 - 23 * 60; |
| 98 | + int hour = secund / 3600; |
| 99 | + System.out.println("Time is " + hour + " : " + minute + " : " + (secund - ((hour * 3600) + (minute * 60)))); |
| 100 | + |
| 101 | + } |
| 102 | +} |
0 commit comments