public class test{
public static void main(String[] args) {
int yiYuan,wuYuyan,shiYuan,total;
System.out.print("請輸入壹元的張數:");
yiYuan = new Scanner(System.in).nextInt();
while(yiYuan < 0){
System.out.println("數量必須大於0,請重新輸入!");
System.out.println("");
System.out.print("請輸入壹元的張數:");
yiYuan = new Scanner(System.in).nextInt();
}
System.out.print("請輸入五元的張數:");
wuYuyan = new Scanner(System.in).nextInt();
while(wuYuyan < 0){
System.out.println("數量必須大於0,請重新輸入!");
System.out.println("");
System.out.print("請輸入五元的張數:");
wuYuyan = new Scanner(System.in).nextInt();
}
System.out.print("請輸入十元的張數:");
shiYuan = new Scanner(System.in).nextInt();
while(shiYuan < 0){
System.out.println("數量必須大於0,請重新輸入!");
System.out.println("");
System.out.print("請輸入十元的張數:");
shiYuan = new Scanner(System.in).nextInt();
}
total = yiYuan + 5 * wuYuyan + 10 * shiYuan;
System.out.println("妳輸入的壹元有:" + yiYuan +"張,五元有:"
+ wuYuyan +"張,十元有:" + shiYuan + "張,總金額是:" + total +"元.");
}
}