<Git> Increment01.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class Increment01 { public static void main(String[] args) { // = 기호는 대입(assign) 연산자입니다. int x = 5 ; // 변수 x를 정의한 다음, 5를 대입(writer)합니다. //x = x + 3 ; // 누적 x += 3 ; // 누적 System.out.println("x : " + x); x *= 4 ; System.out.println("x : " + x); x %= 5 ; System.out.println("x : " + x); x -= 1 ; System.out.println("x : " + x); x += 7 ; System.out.println("x : ..
<Git>MyBox.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class MyBox { public static void main(String[] args) { double width ; double height ; double area ; double perimeter ; width = 10.0 ; height = 5.0 ; area = width * height ; perimeter = 2 * (width+height) ; System.out.println("사각형 넓이 :" +area); System.out.println("사각형 둘레 :" +perimeter); } }
<Git> ErrorDebug.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class ErrorDebug { public static void main(String[] args) { int a,b,c ; a = 21 ; b = 7 ; c = a+b ; System.out.println("a+b = " +c); c = a-b ; System.out.println("a-b =" + c); c = a/b; System.out.println("a/b =" +c); } } cf) Myjava/ErrorDebug.java at master · nolooker/Myjava (github.com)
<Git> Condition02.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class Condition02 { public static void main(String[] args) { int a = 8, b = 7 ; int result = a >= b ? 5 : (a + 2) ; System.out.println("result : " + result); int x = 5 ; result = x%2 == 0 ? x+3 : x*x ; System.out.println("result : " + result); } } cf) Myjava/Condition02.java at master · nolooker/Myjava (github.com)
<Git> CondOper01.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class CondOper01 { public static void main(String[] args) { // 최대값 변수 이름 : max int x = 3 ,y = 8 , z = 4 ; int max = x >= y ? x : y ; max = y >= z ? y : z ; max = y >= (x + z) ? y : z ; System.out.println("최대 수 : " + max); } } cf ) Myjava/CondOper01.java at master · nolooker/Myjava (github.com)
<Git> CondOper.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class CondOper { public static void main(String[] args) { int x = 3, y = 8, z = 4 ; int max = x > y ? x : y ; max = max > z ? max : z ; System.out.println("최대 : " + max); // 최소 값은 ? int min = x z ? x : z) : (y > z ? y : z) ; System.out.println("최대 : " + max); min = x
<Git> Casting.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class Casting { public static void main(String[] args) { double d = 100 ; // 암시적 형변환 System.out.println("d : " + d); // 명시적 형변환 int i = (int)12.5 ; // (int)를 캐스트 연산자라고 함 System.out.println("i : " + i); System.out.println(14/5); // (double)14/5 -> 14.0/5 -> 14.0/5.0 -> 2.8 System.out.println((double)14/5); // (double)(14/5) -> (double)(2) -> 2.0 System.out.p..
<Git> ArithmeticOperator2.java
·
console.log("What ? " + Cord);/Java
package ch01_variable_operator; public class ArithmeticOperator2 { public static void main(String[] args) { int TIME = 8000 ; int hour ; int minute ; int second ; hour = TIME / 3600 ; minute = (TIME - hour * 3600) /60 ; second = TIME % 60 ; System.out.println("시간 : " +TIME); System.out.println("시 : " +hour); System.out.println("분 : " +minute); System.out.println("초 : " +second); System.out.print..