实现百位数之内的位数相加
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 }