tailieunhanh - murachs Java SE 2010 phần 3
Thay vào đó, tác giả Anne Boehm đã cẩn thận phân tích những thay đổi ảnh hưởng đến cách bạn phát triển các ứng dụng web và những gì bạn cần phải học khi. Điều đó có nghĩa là cuốn sách này tích hợp các vật liệu mới với tính năng cổ điển đã không thay đổi, | Chapter 4 How to code control statements 149 The code import import public class FutureValueApp public static void main String args _ _ _ Scanner sc new Scanner String choice y while 1 n get the input from the user Enter monthly Investment double monthlylnvestment Enter yearly interest rate double InterestRate Enter number of years int years convert yearly values to monthly values double monthlylnterestRate interestRate 12 100 int months years 12 call the future value method double futurevalue calculateFutureValue monthlylnvestment monthlylnterestRate months format and display the result NumberFormat currency Future value futurevalue see If the user wants to continue Continue y n choice . a static method that requires three arguments and returns a double private static double calculateFutureValue double monthlylnvestment double monthlylnterestRate Int months _ double futurevalue for Int 1 1 1 months i _ futurevalue futurevalue monthlylnvestment 1 monthlylnterestRate _ return futurevalue Figure 4-14 The Future Value application with a static method Download from Wow eBook 150 Section 1 Essential Java skills Perspective If this chapter has succeeded you should now be able to use if switch while do-while and for statements. These are the Java statements that implement the selection case and iteration structures and they provide the logic of an application. You should also be able to code and call your own static methods which will help you divide your programs into manageable parts. Summary You can use the relational operators to create Boolean expressions that compare primitive data types and return true or false values and you can use the logical .
đang nạp các trang xem trước