Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo sách 'java™ how to program ( deitel - deitel) - phần 4', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 2.2 First Program in Java Printing a Line of Text 2.3 Modifying Our First Java Program 2.4 Displaying Text with printf 2.5 Another Java Application Adding Integers 2.6 Memory Concepts 2.7 Arithmetic 2.8 Decision Making Equality and Relational Operators 2.9 Optional Software Engineering Case Study Examining the Requirements Document 2.10 Wrap-Up Summary Terminology Self-Review Exercises Answers to Self-Review Exercises Exercises PREV NEXT E Page 36 continued 2.1. Introduction We now introduce Java application programming which facilitates a disciplined approach to program design. Most of the Java programs you will study in this book process information and display results. We present six examples that demonstrate how your programs can display messages and how they can obtain information from the user for processing. We begin with several examples that simply display messages on the screen. We then demonstrate a program that obtains two numbers from a user calculates their sum and displays the result. You will learn how to perform various arithmetic calculations and save their results for later use. Many programs contain logic that requires the program to make decisions. The last example in this chapter demonstrates decision-making fundamentals by showing you how to compare numbers then display messages based on the comparison results. For example the program displays a message indicating that two numbers are equal only if they have the same value. We analyze each example one line at a time to help you ease your way into Java programming. To help you apply the skills you learn here we provide many fun and challenging problems in the chapter s exercises. E a Page 36 continued PREV NEXT 2.2. First Program in Java Printing a Line of Text Every time you use a computer you execute various applications that perform tasks for you. For example your e-mail application helps you send and receive e-mail and your Web browser lets you view Web pages from Web sites around the .