COMPUTER 2430 Object Oriented Programming and Data Structures I

Slides:



Advertisements
Similar presentations
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 3: Program Statements 3.6 – Iterators – p
Advertisements

C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Page margin margin for header and footer. page size page orientation.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Today’s topics: I/O (Input/Output). Scribbler Inputs & Outputs  What are the Scribbler’s inputs and outputs?  reset button  motors/wheel  light sensor.
Using Processing Stream. Predefined Streams System.in InputStream used to read bytes from the keyboard System.out PrintStream used to write bytes to the.
CS 177 Recitation Week 8 – Methods. Questions? Announcements  Project 3 milestone due next Thursday 10/22 9pm  Turn in with: turnin –c cs177=xxxx –p.
Files and Streams CS 21a Chapter 11 of Horstmann.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 28, 2005.
Strings as objects Strings are objects. Each String is an instance of the class String They can be constructed thus: String s = new String("Hi mom!");
COMP 14 Introduction to Programming Miguel A. Otaduy May 14, 2004.
***** 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.
Separating Columns in Excel. An extremely useful function in Excel is the Text to Column feature which can be used for any type of column separation but.
2-1 CM0551 Week 3 The scanner class – file input A Spelling Checker Time and space requirements for various dictionary structures.
Using java’s Scanner class To read from input and from a file. (horstmann ch04 and ch 17)
Computer Programming Lab(5).
1 Course Lectures Available on line:
Recitation 1 CS0445 Data Structures Mehmud Abliz.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
CS1101: Programming Methodology Recitation 3 – Control Structures.
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.
CIS 260: App Dev I. 2 Programs and Programming n Program  A sequence of steps designed to accomplish a task n Program design  A detailed _____ for implementing.
Java 1.5 The New Java Mike Orsega Central Carolina CC.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
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.
BHCSI Programming Contests. Three contests Mock Contest #1  Friday, July 16 th  2:15 – 4:45pm UCF High School Online Contest  Thursday, July 22 nd.
1 / 65 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 12 Programming Fundamentals using Java 1.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Interactive Programs Programs that get input from the user 1 In PowerPoint, click on the speaker icon then click the "Play" button to hear the narration.
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 6_1 GEORGE KOUTSOGIANNAKIS Copyright: FALL 2015 Illinois Institute of Technology- George Koutsogiannakis 1.
Introduction to programming in java
Reading from a file and Writing to a file
Project 1.
Objectives You should be able to describe: Interactive Keyboard Input
Compiling and Running a Java Program
Introduction to Computer Science / Procedural – 67130
OBJECT ORIENTED PROGRAMMING II LECTURE 2 GEORGE KOUTSOGIANNAKIS
Building Java Programs
Maha AlSaif Maryam AlQattan
RegExps & DFAs CS 536.
Interactive Standard Input/output
Computer Programming Methodology Input and While Loop
Creating and Modifying Text part 2
Computer Programming Methodology File Input
Testing and Exceptions
Something about Java Introduction to Problem Solving and Programming 1.
Week 6 Discussion Word Cloud.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Program Style Console Input and Output
Exceptions & exception handling
Java for Teachers Intermediate
Exceptions & exception handling
Computers & Programming Languages
COMPUTER 2430 Object Oriented Programming and Data Structures I
Input and Output in Java
Introduction to Classes and Methods
COMPUTER 2430 Object Oriented Programming and Data Structures I
COMPUTER 2430 Object Oriented Programming and Data Structures I
L3. Necessary Java Programming Techniques
L3. Necessary Java Programming Techniques
OBJECT ORIENTED PROGRAMMING II LECTURE 13_1 GEORGE KOUTSOGIANNAKIS
Input and Output in Java
Input and Output in Java
CSC1401 Input and Output (with Files)
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
CSC 1051 – Data Structures and Algorithms I
CSS161: Fundamentals of Computing
CIS 110: Introduction to Computer Programming
Presentation transcript:

COMPUTER 2430 Object Oriented Programming and Data Structures I

File Input import java.io.*; Import java.util.Scanner; public static void main( String args[] ) { Scanner stdin = new Scanner( System.in ); // comment out before submitting to the grader try stdin = new Scanner( new File("Lab6_1.in") ); } catch (Exception ex) System.out.println(ex.toString()); ...

String Method split import java.io.*; Import java.util.Scanner; public static void main( String args[] ) throws IOException { Scanner stdin = new Scanner( System.in ); . . . String cmdLine; String tokens[]; cmdLine = stdin.nextLine(); // “243.15 5” // space “ ” is the only delimiter tokens = cmdLine.split(" "); // tokens[0]: “243.15” // tokens[1]: “5” ... }

Parse Methods String cmdLine; String tokens[]; cmdLine = stdin.nextLine(); // “243.15 5” tokens = cmdLine.split(" "); // tokens[0]: “243.15” // tokens[1]: “5” double dbl = Double.parseDouble(tokens[0]); int qVal = Integer.parseInt(tokens[1]);

The First Token! import java.io.*; Import java.util.Scanner; public static void main( String args[] ) throws IOException { Scanner stdin = new Scanner( System.in ); . . . String cmdLine; String tokens[]; cmdLine = stdin.nextLine(); // “ 243.15 5” tokens = cmdLine.split(" "); // tokens[0]: “” // tokens[1]: “243.15” // tokens[2]: “5” ... }

Parsing String for Date String to parse: “9/30/2009” Delimiter: “/” cmdLine = stdin.nextLine(); tokens = cmdLine.split(“/"); // tokens[0] = “9” // tokens[1] = “30” // tokens[2] = “2009” // Convert to integer int day = Integer.parseInt(tokens[1]);

Parsing String for Complex String to parse: “(3.5,7.213)” Delimiters: “(,)” cmdLine = stdin.nextLine(); tokens = cmdLine.split(“[(,)]"); // tokens[0] = “” // tokens[1] = “3.5” // tokens[2] = “7.213” // Convert to double Double real = Double.parseDouble(tokens[1]);

Programming Grand Rules Most the same as CS 1430 Each line has at most 78 columns Indent 3 spaces No tab keys Braces on separate lines One space before and one space after operator

Formatting Setting K:\academic\csse\software\ NetBeans_8.1_JDK_8u91\NetBeans.txt NetBeansSettings.zip

NetBeans Formatting Tools->Options->Editor->Formatting tab Select All Languages Select Tabs And Indents Check: Expand Tabs to Spaces Number of Spaces per Indent: 3 Tab Size: 3 Right Margin: 78

NetBeans Formatting Tools->Options->Editor->Formatting tab Select Language Java Select Tabs And Indents Continuation Indent Size: 6 Select Braces Select New Line for all under Braces Placement Select Generate for all under Braces Generation Select Alignment Check : else, finally, while, catch Uncheck: after modifier Uncheck all under Multiline Alignment Select Comments Uncheck: Add Leading Star

NetBeans Formatting Tools->Templates Select Java then Java class Click Open in Editor Change <#assign licenseFirst = "/*"> to <#assign licenseFirst = "/**"> (adding one "*") Change <#assign licensePrefix = " * "> to <#assign licensePrefix = ""> (" * " to "") Change <#assign licenseLast = " */"> to <#assign licenseLast = "*/"> (removing space in " */")

NetBeans Formatting Tools->Templates Change /** * * @author ${user} */ to @author ${user}

NetBeans Formatting Tools->Templates Change public class ${name} { } to public class ${name} {

NetBeans Formatting Turn off NetBeans updates: Tools --> Plugins --> Settings tab Automatically Check for Updates, Check Interval = Never