package java.util.Scanner;
public class Lucky {
public static void main(String[] args) {
int custNo;
System.out.println("請輸入4位會員卡號:");
Scanner input=new Scanner(System.in);
custNo=input.nextln();
System.out.println("會員卡號是:"+custNo);
int gewei=custnNo%10;
int shiwei=custNo/10%10;
int baiwei=custNo/100%10;
int qianwei=custNo/1000;
System.out.println("千位數:"+qianwei+"百位數:"+baiwei+"十位數:"+shiwei+"個位數:"+gewei);
int sum=gewei+shiwei+baiwei+qianwei;
System.out.println("會員卡號"+custNo+"各位之和:"+sum);
if(sum>20){
System.out.println("會員卡號"+custNo+"的會員,您中獎了!獎品是MP3!");
System.out.println("會員卡號"+custNo+"的會員,您沒有中獎");
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/177089.html
標籤:Java相關
上一篇:主要是最后一個要求!
下一篇:[網路安全]SSH服務簡介
