Lecture Fundamentals of computing 1: Lecture 3 - Duy Tan University

Lecture Fundamentals of computing 1 - Lecture 3 introduce the console Input and Output. This chapter presents the following content: Console output, using imported class, scanner class, common pitfalls. Inviting you refer. | Lecture Title: Console Input and Output Fundamentals of Computing 1 Agenda Console output Using imported class Scanner class Common pitfalls ask them, how might the computer store "hi" using binary digits? (some kind of mapping; ASCII) for console output is an object that is part of the Java language println is a method invoked by the object that can be used for console output The data to be output is given as an argument in parentheses A plus sign is used to connect more than one item Every invocation of println ends a line of output ("The answer is " + 42); Console Input What if we want to let the users choose any values they want to use ? We can prompt the user by console (keyboard) input Console Input Import instruction Create Scanner object Read a first integer and assign it to variable a Read a second integer and assign it to variable b Agenda Console output Using imported class Scanner class Common pitfalls ask them, how might the computer store "hi" using binary digits? (some kind of mapping; ASCII) Importing Packages and Classes Libraries in Java are called packages A package is a collection of classes that is stored in a manner that makes it easily accessible to any program In order to use a class that belongs to a package, the class must be brought into a program using an import statement Classes found in the package are imported automatically into every Java program import ; // import theNumberFormat class only import .*; //import all the classes in package Using * Agenda Console output Using imported class Scanner class Common pitfalls ask them, how might the computer store "hi" using binary digits? (some kind of mapping; ASCII) Console Input Using the Scanner Class Starting with version , Java includes a class for doing simple keyboard input named the Scanner class In order to use the Scanner class, a program must include the . | Lecture Title: Console Input and Output Fundamentals of Computing 1 Agenda Console output Using imported class Scanner class Common pitfalls ask them, how might the computer store "hi" using binary digits? (some kind of mapping; ASCII) for console output is an object that is part of the Java language println is a method invoked by the object that can be used for console output The data to be output is given as an argument in parentheses A plus sign is used to connect more than one item Every invocation of println ends a line of output ("The answer is " + 42); Console Input What if we want to let the users choose any values they want to use ? We can prompt the user by console (keyboard) input Console Input Import instruction Create Scanner object Read a first integer and assign it to variable a Read a second integer and assign it to variable b Agenda Console output Using imported class Scanner class Common pitfalls ask

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.