从控制台读取的除整数,还可以得到余数
import java.util.Scanner; /*n o w j a v a . c o m - 时 代 Java 提供*/ public class MarblesApp { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { // declarations int numberOfMarbles; int numberOfChildren; int marblesPerChild; int marblesLeftOver; // get the input data numberOfMarbles = 50; System.out.print("Number of children: "); numberOfChildren = 7; /* 来自 时 代 J a v a - nowjava.com*/ // calculate the results marblesPerChild = numberOfMarbles / numberOfChildren; marblesLeftOver = numberOfMarbles % numberOfChildren; // print the results System.out.println("Give each child " +