본문 바로가기

프로그래밍/자바소스 및 자료

[자바소스] 구구단 출력 프로그램(while문 사용)

스캐너를 이용한 구구단 출력 프로그램 입니다.

1. P1.java 파일입니다.
import java.util.Scanner;

public class P1 {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("구구단 프로그램입니다.");
System.out.print("단수를 입력하세요. : ");
int number=input.nextInt();
int count=1;

while(count<10){
System.out.printf("%s * %s = %s\n", number, count, number*count);
count++;
}
}
}

2. 결과 입니다.



잘 사용하세요 ^^