[2024 동계 모각코]

[2024 동계 모각코] 1회차 개인 목표 및 결과

multipotentialite1 2025. 1. 3. 16:11

일시 : 2025.01.01 14:00 ~ 18:00

 

[1회차 목표]

- JAVA,Eclipse 설치 및 코딩 환경 구축

- JAVA 입출력(Scanner)구문 학습 및 반복문, 조건문 구문 학습

 

[1회차 결과]

- JAVA 및 Eclipse 설치 및 코딩 환경 구축을 완료하였습니다.

- JAVA 기본적인 입출력 구문을 학습하였으며, 반복문과 조건문 구문을 학습하였습니다.

JAVA 프로그래밍 환경 구축 및 JDK 설치 완료
Eclipse 프로그래밍 환경 구축 및 UTF-8 인코딩 설정 완료

 

- Class 첫 문자는 대문자로 설정

- 기본 출력

public class Re_Helloworld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

- 입출력

import java.util.Scanner;

public class P1000_AplusB {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(A + B);
    }
}

- 사칙연산

import java.util.Scanner;

public class P10869_All {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(A + B);
        System.out.println(A - B);
        System.out.println(A * B);
        System.out.println(A / B);
        System.out.println(A % B);
    }
}

 - JAVA에서 int/int의 경우 소수점 자리 없이 정수로 출력되므로 double/double의 형태로 입출력할 수 있도록 변환해주어야 함.

 

- if / else if / else 조건문

import java.util.Scanner;

public class 조건문복습 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > b) {
            System.out.println(a);
        } else if (a == b) {
            System.out.println("same");
        } else {
            System.out.println(b);
        }
    }
}

- 조건문 시험성적 구하기 예제

import java.util.Scanner;

public class P9498_시험성적 {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();

    if (90 <= A) {
        System.out.println("A");
    } else if (80 <= A) {
        System.out.println("B");
    } else if (70 <= A) {
        System.out.println("C");
    } else if (60 <= A) {
        System.out.println("D");
    } else {
        System.out.println("F");
        }
    }
}

 

- For, While 반복문

public class 반복문복습 {
    public static void main(String[] args) {
    for(int i = 0; i < 5; i++) {
        System.out.println(i);
    }

    int i = 0;
    while (i < 5) {
        System.out.println(i);
        i++;
    }
    }
}