ZanJoye的破站

解析三位数的位数

25/10/21
5
0
package unit1;
import java.util.Scanner;
public class HelloWorld {
	public static void main(String[] args) {
		Integer toProcess = 0;
		int bai,shi,ge;		//定义个十百的变量
		Scanner input = new Scanner(System.in);	//创造一个输入对象
		System.out.print("请输入一个三位数字:");
		StringBuffer tmp = new StringBuffer();
		final String e = "exit";
		for(;;) {
		tmp.replace(0,4,input.nextLine());	//存储待处理的值
		if(tmp.toString().equalsIgnoreCase(e) != false) {
			break;
		}
		System.out.println(tmp.toString());
		toProcess = toProcess.valueOf(tmp.toString());
		bai = toProcess/100;	//处理百位
		shi = toProcess/10 - bai*10;	//处理十位
		ge = toProcess%10;	//处理个位
		System.out.println("百:"+bai+" 十:"+shi+" 个:"+ge);
		}
	}
}