1. 소스 설명
for문을 사용한 구구단 출력 프로그램입니다.
while문을 사용한 구구단 출력 프로그램과 동일합니다.
while문을 사용한 구구단 출력 프로그램과 동일합니다.
2.소스 : 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();
for(int i=1; i<10; i++)
System.out.printf("%s * %s = %s\n", number, i, number*i);
}
}
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();
for(int i=1; i<10; i++)
System.out.printf("%s * %s = %s\n", number, i, number*i);
}
}
3.결과
'프로그래밍 > 자바소스 및 자료' 카테고리의 다른 글
[자바소스] 피보나치 수열 방법2(재귀함수) (0) | 2011.07.28 |
---|---|
[자바소스] 피보나치 수열 방법1(반복문) (0) | 2011.07.28 |
[자바소스] 구구단 출력 프로그램(while문 사용) (0) | 2011.07.27 |
[자바소스] 단위변환(kilos,grams,pounds,ounces) (0) | 2011.07.26 |
[자바소스] 마우스로 연속된 선 그리기 (0) | 2011.07.26 |