实现百位数之内的位数相加

 1 import javax.swing.JOptionPane;
 2 public class plusFactor {
 3     public static void main(String[] args){
 4             int value,valueH,valueD,valueN;
 5             value = (int)(Math.random()*1000);
 6             JOptionPane.showMessageDialog(null, "the random value is " + value);
 7             valueH = value / 100;
 8             valueD = value % 100 / 10;
 9             valueN = value % 10;
10             JOptionPane.showMessageDialog(null, "the plus result is " 
11             + (valueH + valueD + valueN));
12     }
13 }

 

posted @ 2014-08-03 11:58  Amoxicil  阅读(155)  评论(0编辑  收藏  举报