본문 바로가기

WIL(What I Learned)

(자바 플레이그라운드) 구구단 추가과제 메서드 학습

import java.util.Scanner;

public class GugudanMain {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String inputValue = scanner.nextLine();

        String[] splitedValue = inputValue.split(",");
        int first = Integer.parseInt(splitedValue[0]);
        int second = Integer.parseInt(splitedValue[1]);

        for (int i = 2; i < first + 1; i++) {
            for ( int j = 1; j < second+1; j++ )
            {
                System.out.println(i*j);
            }
    }
    }
}

 

<사용된 메서드>

Scanner scanner = new Scanner(System.in);
String inputValue = scanner.nextLine();
String[] splitedValue = inputValue.split(",");
int first = Integer.parseInt(splitedValue[0]);
int second = Integer.parseInt(splitedValue[1]);