A.5 Another Application: Adding Integers
Our next application reads (or inputs) two integers (whole numbers, such as −22, 7, 0 and 1024) typed by a user at the keyboard, computes their sum and displays it. Programs remember numbers and other data in the computer’s memory and access that data through program elements called variables. The program of Fig. A.7 demonstrates these concepts. In the sample output, we use bold text to identify the user’s input (i.e., 45
and 72
).
Import Declarations
Lines 1–2 state the figure number, file name and purpose ...
Get Android How to Program, 3/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.