ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • workshop01
    멋사 부트캠프/과제 2025. 3. 5. 20:17

    public class Test01 {

     

    public static void main(String[] args) {

    int a = 100;

    double pi = 3.14;

    char ch = 'A';

    boolean bool = true;

     

    System.out.println("정수형 변수의 값은 "+ a + " 이며 " + "자료형은 " + ((Object)a).getClass().getSimpleName());

    System.out.println("실수형 변수의 값은 "+ pi + " 이며 " + "자료형은 " + ((Object)pi).getClass().getSimpleName());

    System.out.println("정수형 변수의 값은 "+ ch + " 이며 " + "자료형은 " + ((Object)ch).getClass().getSimpleName());

    System.out.println("정수형 변수의 값은 "+ bool + " 이며 " + "자료형은 " + ((Object)bool).getClass().getSimpleName());

    }

     

    }

    public class Test02 {

     

    public static void main(String[] args) {

    String s1 = "1";

    String s2 = "2";

    boolean bnx = false;

    char c1 = 'A';

    char c2 = 'B';

    char c3 = 'C';

    char c4 = 'D';

    int inx = 2;

     

    System.out.println(s1 + s2);

    System.out.println(!bnx);

    System.out.println(inx+129);

    System.out.println(inx+49);

    System.out.println(inx+97);

    }

    }

     

    public class Test03 {

     

    public static void main(String[] args) {

    int num = 45678;

    int result = ((num / 1000) << 10)-1080;

     

    System.out.println("기존 숫자 : " + num);

    System.out.println("비트 연산 후 변환된 숫자 : " + result);

    }

    }

    public class Test04 {

     

    public static void main(String[] args) {

    char ch = 'G';

     

    String result = (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ? "입렵한 문자 " + ch + " 는 영문자입니다." : "아님.";

     

    System.out.println(result);

    }

    }

    public class Test05 {

     

    public static void main(String[] args) {

    int fahrenheit = 100;

    float celcius = (float)5/9 * (fahrenheit-32);

     

    System.out.println("Fahrenheit : " + fahrenheit);

    System.out.println("celcius : " + celcius);

    }

    }

     

    public class Test06 {

     

    public static void main(String[] args) {

    byte a = 10;

    byte b = 20;

    byte c = (byte)(a+b);

    char ch = 'A';

    ch = 'C';

    float f = 1.5f;

    long l = 27000000000L;

    float f2 = 0.1f;

    double d = 0.1f;

    boolean result = (float)d == 0.1f ? true : false;

     

    System.out.println("c = " + c);

    System.out.println("ch = " + ch);

    System.out.println("f = " + f);

    System.out.println("l = " + l);

    System.out.println("result = " + result);

    }

    }

    public class Test07 {

     

    public static boolean isAlpahbet(char ch) {

    return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');

    }

     

    public static void printResult(char ch) {

    String result = isAlpahbet(ch) ? "입력한 문자 " + ch + "는 영문자입니다." : "아님.";

     

    System.out.println(result);

    }

     

    public static void main(String[] args) {

    char ch = 'G';

     

    printResult(ch);

    }

    }

     

    '멋사 부트캠프 > 과제' 카테고리의 다른 글

    사전 과제  (0) 2025.02.27
Designed by Tistory.