WUSTL CSE 131 - sp14_4 (28 pages)

Previewing pages 1, 2, 3, 26, 27, 28 of 28 page document View the full content.
View Full Document

sp14_4



Previewing pages 1, 2, 3, 26, 27, 28 of actual document.

View the full content.
View Full Document
View Full Document

sp14_4

267 views


Pages:
28
School:
Washington University in St. Louis
Course:
Cse 131 - Computer Science I
Computer Science I Documents

Unformatted text preview:

1 5 Input and Output Introduction to Programming in Java An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 1 14 19 07 13 03 AM Input and Output Input devices Keyboard Mouse Hard drive Network Digital camera Speakers Hard drive Network Printer Microphone Output devices Display MP3 Player Goal Java programs that interact with the outside world 2 Operating Systems Our approach Define Java libraries of functions for input and output Use operating system OS to connect Java programs to file system each other keyboard mouse display speakers 3 Terminal Terminal Application where you can type commands to control the operating system We have been running programs in eclipse where output is directed to the Console Window If you use the Sedgewick library for input you can supply values by typing them into the Console Window Mac OS X Microsoft Windows 4 Command Line Input and Standard Output Command line input Read an integer N as command line argument Standard output Flexible OS abstraction for output In Java output from System out println goes to standard output By default standard output is sent to Terminal Example output N random numbers public class RandomSeq public static void main String args int N Integer parseInt args 0 for int i 0 i N i System out println Math random 5 Old Bird s Eye View The ArgsProcessor implementation we have been using accepts commandline arguments but if they are not present it prompts the user for the required inputs 6 New Bird s Eye View Useful for lots of data Useful for providing just a few inputs such as for configuring a program 7 Command Line Input vs Standard Input Command line input Use command line input to read in a few user values Not practical for many user inputs Input entered before program begins execution Standard input Flexible OS abstraction for input By default standard input is received from Terminal window Input entered while program is executing 8 Standard Input and Output Standard input



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view sp14_4 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view sp14_4 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?