Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.

Slides:



Advertisements
Similar presentations
Chapter 10 Ch 1 – Introduction to Computers and Java Streams and File IO 1.
Advertisements

MOD III. Input / Output Streams Byte streams Programs use byte streams to perform input and output of 8-bit bytes. This Stream handles the 8-bit.
A Bridge to Your First Computer Science Course Prof. H.E. Dunsmore Computers Memory Number Systems Software Java.
Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Some basic I/O.
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Writing algorithms using the while-statement. Previously discussed Syntax of while-statement:
***** SWTJC STEM ***** Chapter 3-1 cg 36 Java Class Libraries & API’s A class library is a set of classes that supports the development of programs. Java.
LAB 10.
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
Computer Programming Lab(5).
“Introduction to Programming With Java”
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
COMP 110: Introduction to Programming Tyler Johnson January 14, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
Programming Concept Chapter I Introduction to Java Programming.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Java Fundamentals 3 Input and Output statements. Standard Output Window Using System.out, we can output multiple lines of text to the standard output.
Week 2 - Wednesday.  What did we talk about last time?  Data representation  Binary numbers  Types  int  boolean  double  char  String.
CS61B L02 Using Objects (1)Garcia / Yelick Fall 2003 © UCB Kathy Yelick Handout for today: These lecture notes Computer Science 61B Lecture 2 – Using Objects.
Input/Output in Java. Output To output to the command line, we use either System.out.print () or System.out.println() or System.out.printf() Examples.
JAVA PROGRAMMING BASICS CHAPTER 2. History of Java Begin with project Green in 1991 founded by Patrick Noughton, Mike Sheridan and James Gosling who worked.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
Introduction to Programming
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
Using the while-statement to process data files. General procedure to access a data file General procedure in computer programming to read data from a.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
Truth and while Today 15 Minutes online time to finish the random/Swing programs. Truth tables: Ways to organize results of Boolean expressions. Note Taking:
Reading input from the console input. Java's console input The console is the terminal window that is running the Java program I.e., that's the terminal.
Software Development Introduction
Martin T. Press.  Main Method and Class Name  Printing To Screen  Scanner.
Computer Programming Lab 9. Exercise 1 Source Code package excercise1; import java.util.Scanner; public class Excercise1 { public static void main(String[]
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 6_1 GEORGE KOUTSOGIANNAKIS Copyright: FALL 2015 Illinois Institute of Technology- George Koutsogiannakis 1.
A.P. Computer Science Input is NOT tested on the AP exam, but if we want to do any labs, we need input!!
Introduction to programming in java
For Friday Finish reading chapter 9 WebCT quiz 17.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Foundations of Programming: Java
Introduction to Object Oriented
Streams & File Input/Output (I/O)
Introduction to programming in java
Exercise 1- I/O Write a Java program to input a value for mile and convert it to kilogram. 1 mile = 1.6 kg. import java.util.Scanner; public class MileToKg.
CSC1401 Input and Output (and we’ll do a bit more on class creation)
Software Development Packages
CSC305: COMPUTER PROGRAMMING II (JAVA)
Maha AlSaif Maryam AlQattan
TK1114 Computer Programming
Comp Sci 200 Programming I Jim Williams, PhD.
Something about Java Introduction to Problem Solving and Programming 1.
INPUT STATEMENTS GC 201.
Writing Methods.
Computers & Programming Languages
An Introduction to Java – Part I, language basics
Introduction to Java Brief history of Java Sample Java Program
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
Truth tables: Ways to organize results of Boolean expressions.
Building a program (Java libraries) - an example
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
F II 2. Simple Java Programs Objectives
Presentation transcript:

Input & Output In Java

Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at dealing with data it still needs to translate that data into a format that is understandable to users. (OUTPUT) Users also have to provide information that the computer can understand (INPUT) The Java programming language uses several strategies to be able to handle input an output. Java treats input and output data as streams of bytes (groups of 8 bits with integer values)

Handling Input & Output - I/O Until now we have dealt with one program that is made up of only one file. Ex: Hello.java From this simple program we have been able to output information using the System.out.println(); statement. This works for simple text output. It does not work well for more complex outputs like pictures. Fortunately the Java programming language has files (programs) that can help handle more complex inputs and outputs.

Importing classes & packages A class is a collection of instructions and information. A package is a collection of classes which may used in your program. Think of a package as a tool box and the classes within it as tools. Different programs need different tools and include different packages. Classes and packages can be created elsewhere and then imported into your program.

The Scanner Class The scanner class helps handle input To import into your program use the import command Syntax is as follows: import java.util.Scanner; public static void main(String[] args) { Scanner input=new Scanner (System.in); //more lines of code }

In and Out classes The in class handles input The Out class handles output They have been created specifically for this course using the resource from The textbook “An Introduction to Computer Science Using Java” (John Carter). Instructions on how to use these classes are in the text: Appendix A.