1.5 input output

1.5 input output - 1.5 Input and Output Introduction to...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1.5 Input and Output Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2008 September 20, 2008 4:32 PM 2 Input and Output Input devices. Output devices. Goal. Java programs that interact with the outside world. Display Speakers MP3 Player Printer Mouse Keyboard Digital camera Microphone Hard drive Network Hard drive Network 3 Input and Output Input devices. Output devices. 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. Display Speakers MP3 Player Printer Mouse Keyboard Digital camera Microphone Hard drive Network Hard drive Network 4 Digital Michelangelo Project Goal. Precise 3D description of the David. ! Laser rangefinder. ! 5,000 hours of scanning, 32 Gigabytes ! 5 Terminal. Application where you can type commands to control the operating system. Terminal Mac OS X Microsoft Windows 6 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 stdout . ! By default, stdout is sent to Terminal. public class RandomSeq { public static void main ( String args ) { int N = Integer . parseInt ( args [ ]); for ( int i = ; i < N ; i ++) { System . out . println ( Math . random ()); } } } % java RandomSeq 4 0.9320744627218469 0.4279508713950715 0.08994615071160994 0.6579792663546435 7 Old Bird's Eye View 8 New Bird's Eye View Standard Input and Output 10 Command-line Input vs. Standard Input Command line inputs. ! Use command line inputs 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, stdin is received from Terminal window. ! Input entered while program is executing. 11 Standard Input and Output Standard input. We provide library StdIn to read text input....
View Full Document

Page1 / 8

1.5 input output - 1.5 Input and Output Introduction to...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online