6.24作业
1、练习1
2.练习2
3.练习3
4.练习4
package com.z1;
import java.util.Scanner;
public class lucky {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("请输入4位会员卡号:");
int number = sc.nextInt();
int qianwei = number/1000;
int baiwei = number%1000/100;
int shiwei = number/10%10;
int gewei = number%10;
System.out.println("千位数:"+qianwei+",百位数:"+baiwei+",十位数"+shiwei+",个位数"+gewei);
int sumNumber = qianwei + baiwei + shiwei + gewei;
System.out.println("会员卡号"+number+"的各位之和是:"+sumNumber);
if(sumNumber>20) {
System.out.println("会员卡号"+number+"的会员,您中奖了! 奖品是mp3!");
}else {
System.out.println("会员卡号:\"+number+\"的会员,您没有中奖");
}
}
}