/*
* File: Add2Integers.java
* -----------------------
* This program adds two integers and prints their sum.
*/
import acm.program.*;
public class Add2Integers extends ConsoleProgram {
public void run() {
println("This program adds two integers.");
int n1 = readInt("Enter n1: ");
int n2 = readInt("Enter n2: ");
int total = n1 + n2;
println("The total is " + total + ".");
}
}
java console program demo quote from Stanford cs106a, "the art and science of java"
最新推荐文章于 2021-02-27 14:42:02 发布