/*
* Copyright (c) 2015,烟台大学计算机学院
* All right reserved.
* 文件名:helloworld.java
* 作者:柴银平
* 完成时间:2015年9月8日
* 版本号:v1.0
*
* 问题描述:计算把一个一千以内的数个十百位相加
*
* 程序输入:输入一个0到1000的数
* 程序输出: 输出计算后的结果
*/
import java.util.Scanner;
public class sayhello {
/**
* @param args
*/
public static void main(String[] args) {
Scanner in=new Scanner (System.in);
System.out.print("Enter a number 0 and 1000:");
int a = in.nextInt();
int b = a/10;
int c=a%10+b%10+b/10;
System.out.println("The sum of the digits is "+c);
}
}
个人感受:还很不熟悉,需要更多的练习!