it/programming
[JAVA] 나누기 몫, 나머지 구하기
훈솔
2013. 3. 27. 11:31
728x90
import java.util.Scanner; public class scan { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a=1, b=1; while(a+b!=0) { System.out.print("정수 2개 입력(피제수 제수 순으로 입력) : "); a = sc.nextInt(); b = sc.nextInt(); if(b!=0) System.out.println(a + " 나누기 " + b + " : 몫" + (a/b) + ", 나머지 " + (a%b)); else if(a!=0) System.out.println("제수가 0이면 안 된다."); } System.out.println("종료합니다."); } }