Java 1.5 AP Computer Science

Slides:



Advertisements
Similar presentations
Chapter 8 Improving the User Interface
Advertisements

Strings Input/Output scanf and printf sscanf and sprintf gets and puts.
Chapter 2 Console Input and Output Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf 9.4Printing Integers 9.5Printing Floating-Point.
The scanf Function The scanf function reads input from the standard input device into one or more variables Example: scanf(“%lf”, &miles); Reads a real.
Chapter 2 Console Input and Output Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
 2007 Pearson Education, Inc. All rights reserved C Formatted Input/Output.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Console Input Using the Scanner Class Starting with version 5.0, Java includes a class for doing.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
The printf Method The printf method is another way to format output. It is based on the printf function of the C language. System.out.printf(,,,..., );
 2007 Pearson Education, Inc. All rights reserved C Formatted Input/Output.
Introduction to Information and Computer Science Computer Programming Lecture c This material (Comp4_Unit5c), was developed by Oregon Health and Science.
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
05/09/2015SJF L31 F21SF Software Engineering Foundations Formatting Converting numbers to Strings and vice versa Monica Farrow EM G30
 2000 Prentice Hall, Inc. All rights reserved. Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
Chapter 9 Formatted Input/Output Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
EPSII 59:006 Spring Introduction In this lecture  Formatted Input/Output scanf and printf  Streams (input and output) gets, puts, getchar, putchar.
Comp 248 Introduction to Programming Chapter 2 - Console Input & Output Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
Chapter 2 Console Input and Output Slides prepared by Rose Williams, Binghamton University Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Console Input & Output CSS 161: Fundamentals of Computing Joe McCarthy 1.
Sahar Mosleh California State University San MarcosPage 1 System.out.println for console output System.out is an object that is part of the Java language.
Slides prepared by Rose Williams, Binghamton University Chapter 2 Console Input and Output.
C Programming Lecture 5 : Basic standard I/O Lecture notes : courtesy of Ohio Supercomputing Center, science and technolgy support.
LYNN BRADSHAW CREATING WEB SITES WITH XARA WEB DESIGNER 7.
02 Variables1November Variables CE : Fundamental Programming Techniques.
CMSC 202 Java Console I/O. July 25, Introduction Displaying text to the user and allowing the user to enter text are fundamental operations performed.
1 CHAPTER 3 StringTokenizer. 2 StringTokenizer CLASS There are BufferedReader methods to read a line (i.e. a record) and a character, but not just a single.
Introduction to Computing Concepts Note Set 12. Writing a Program from Scratch public class SampleProgram1 { public static void main (String [] args)
Lecture 4 – Scanner & Style. Console Output The console that starts a Java application is typically known as the standard output device. The standard.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
Copyright © Curt Hill Formatting Reals Outputs other than normal.
Formatted Output (printf) CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Dale Roberts Introduction to Java - Input, Program Control and Instantiation Dale Roberts, Lecturer Computer Science, IUPUI
Slides prepared by Rose Williams, Binghamton University Console Input and Output.
© A+ Computer Science - import java.util.Scanner; Try to be as specific as possible when using an import.
A.P. Computer Science Input is NOT tested on the AP exam, but if we want to do any labs, we need input!!
Formatted Output (printf) CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
Lecture 4 – Scanner & Style
28 Formatted Output.
Chapter 9 - Formatted Input/Output
User Input ICS2O.
C Formatted Input/Output
Input and Output: I/O Finish reading chapters 1 and 2 of the text
Formatted Output (printf)
Objectives You should be able to describe: Interactive Keyboard Input
Programming Fundamentals
Introduction to Computer Science / Procedural – 67130
TMF1414 Introduction to Programming
Introduction to C CSE 2031 Fall /3/ :33 AM.
Console Input and Output
Computer Programming Methodology File Input
Web Programming– UFCFB Lecture 9
OUTPUT STATEMENTS GC 201.
A+ Computer Science INPUT.
Chapter 9 - Formatted Input/Output
© A+ Computer Science - OOP Pieces © A+ Computer Science -
A+ Computer Science INPUT.
The keyboard is the standard input device.
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Web Programming– UFCFB Lecture 9
Introduction to C CSE 2031 Fall /15/2019 8:26 AM.
Input and Formatted Output (printf)
Presentation transcript:

Java 1.5 AP Computer Science Zawinski's Law: “Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.” Coined by Jamie Zawinski (who called it the “Law of Software Envelopment”) to express his belief that all truly useful programs experience pressure to evolve into toolkits and application platforms (the mailer thing, he says, is just a side effect of that). It is commonly cited, though with widely varying degrees of accuracy. - The Hacker's Dictionary, Jargon File version 4.4.7 Java 1.5

Java 1.5 It is coming Beta is available on the web right now Lots of useful and helpful changes A summary today using slides from Sun They left out some of the most useful things, standard and easy to use mechanisms for input / output Also an email from APCS development committee on what is likely to be adapted, probably next year Java 1.5

Improved Output Java 1.5 has a C style printf method printf can be used to format text output out.printf("%s \n", "a string"); // strings out.printf("%d \n", 1212); // ints out.printf("%f \n", 123.1234); // real numbers Java 1.5

Formatting with printf out.printf("%.2f \n", 123.1199); // results in 123.12 being output out.printf("%5.3f \n", 4.2399); // results in 4.240 being output The 5 in the 5.2 has no real effect Java 1.5

More Formatting with printf out.printf("%20s \n", "a string"); out.printf("%-20s \n", "a string"); %20 = column width of 20 spaces default left aligned - signals right alignedzz Java 1.5

Old Input old style input using Java standard classes as opposed to a third party class BufferedReader keyboard = new BufferedReader ( new InputStreamReader(System.in)); try { String str = keyboard.readLine(); int n = Integer.parseInt(str); System.out.println(n); } catch(Exception e) { System.out.println("An error occurred while" + " attempting to read: " + e ); // GACK!!! Java 1.5

New Input Scanner keyboard = Scanner.create(System.in); int n = keyboard.nextInt(); double d = keyboard.nextDouble(); // Ahhh // On to the slides from Sun Java 1.5