/* * Author: Johann Bach * MAT 2170, Section 1 * Exercise: Lab 1, #2 * Date: August 28, 2007 * File: Add2Integers.java * Purpose: This program requests two integers * from the user, adds them together, and displays * the sum. * */ import acm.program.*; public class Add2Integers extends ConsoleProgram { public void run() { // Prompt for and obtain two integers from the user, // then find and display their sum print("This program adds two integers.\n"); int n1 = readInt("Enter first integer : "); int n2 = readInt("Enter second integer : "); int total = n1 + n2; println("The total of " + n1 + " plus " + n2 + " is " + total + "."); } // end of run() public static void main(String[] args){ new Add2Integers().start(args); } // end of main() } // end of class Add2Integers