javaで標準入力からデータを読む

PKUのHangoverの問題でテストした。eclipseの補完機能は楽だなー

http://acm.pku.edu.cn/JudgeOnline/problem?id=1003

import java.util.Scanner;

public classHangover {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double d, s;
		int n;
		while ((d = sc.nextDouble()) != 0.0) {
			for (n = 0, s=0.0; s < d; n++)
				s += 1. / (n + 2);
			System.out.println(n + " card(s)");
		}
	}
}