/**
* 目的:求各位之和
* @author chenyanlong
* 时间:2017/10/14
*/
package com.hp.test02;
import java.util.Scanner;
public class HS_LuckyNumSum {
public static void main(String[] args) {
// TODO Auto-generated method stub
int num;
System.out.println("请输入4位会员卡号:");
Scanner input=new Scanner(System.in);
num=input.nextInt();
System.out.println("会员卡号是:"+num);
System.out.println("千位:"+num/1000);
System.out.println("百位:"+num/100%10);
System.out.println("十位:"+num/10%10);
System.out.println("个位:"+num%10);
int sum=num/1000+num/100%10+num/10%10+num%10;
System.out.println("会员卡号"+num+"各位之和:"+sum);
}
}
1 /** 2 * 目的:在控制台打印个人简历信息 3 * @author chenyanlong 4 * 时间:2017/10/14 5 */ 6 package com.hp.test02; 7 8 public class HS_ShowMessage { 9 10 public static void main(String[] args) { 11 // TODO Auto-generated method stub 12 String name="黑石"; 13 int age=22; 14 char sex='男'; 15 String position="java工程师"; 16 17 System.out.println("姓名:"+name); 18 System.out.println("年龄:"+age); 19 System.out.println("性别:"+sex); 20 System.out.print("职位:"+position); 21 22 } 23 }
1 /** 2 * 目的:Scanner的基本用法 3 * @author chenyanlong 4 * 时间:2017/10/14 5 */ 6 package com.hp.test02; 7 8 import java.util.Scanner;//导入的Scanner类 9 10 public class HS_TypeChange { 11 12 public static void main(String[] args) { 13 // TODO Auto-generated method stub 14 int number;//会员卡号 15 System.out.println("请输入会员卡号"); 16 17 Scanner input=new Scanner(System.in);//System.in系统键盘输入 18 number=input.nextInt(); 19 System.out.println("会员卡号为:"+number); 20 } 21 22 }