/*********************************** While文その2(合計と平均) ************************************/ import java.util.*; public class While02Total { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int number; int total=0; int count=0; double ave=0; System.out.print("数を入れて下さい(0で終了)\n-->"); number=sc.nextInt(); while( number!=0 ) { total=total+number; count++; System.out.print("-->"); number=sc.nextInt(); } System.out.print("\n合計="+total); System.out.print("\n件数="+count); ave=(double)total/count; System.out.print("\n平均="+ave); } }