import java.util.Scanner; public class day01{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); boolean boo = true; int positiveNumber = 0;//正數 int negativeNumber = 0;//負數 while (boo) { System.out.println("請輸出一個數字:"); int number = sc.nextInt(); if (number>0) { positiveNumber++; }else if (number<0) { negativeNumber++; }else { break; } } System.out.println("正數個數為:"+positiveNumber+"負數個數為:"+negativeNumber); } }