Scanner sc = new Scanner(System.in);

double input, sum;

sum=0;

 

for(int i=0); i<5; i++) {

System.out.print("수 ? ");

input = sc.nextDouble();

if(input <=0.0){

continue; // 0보다 작으면 i++로 간다. 즉 밑에 더하기를 실행하지 않음.

}

sum+=input;

}

System.out.println("결과 : " + sum);

sc.close();

+ Recent posts