03 java program

Uploaded from authorPOINTLite
Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Anatomy: 

Anatomy

Moore’s law: 

Moore’s law Computing power doubles closes to every two years Applicable since 1890

Power: 

Power Apollo moon mission computer 3840 bytes = 30720 bits Lab PC 512 MB = 512 * 1024 Kilobytes = 512 * 1024 * 1024 bytes 512 MB = 536870912 bytes 512 MB = 512 * 1024 * 1024 * 8 bits 512 MB = 4294967296 bits Ratio 4294967296 / 30720 = 139810.1333… Implication 17 doublings in power Time lapse – 38 years

Kurzweil’s law: 

Kurzweil’s law Complexity increases exponentially

Blade law: 

Blade law

Computer organization: 

Computer organization

Computer Organization: 

Computer Organization Input Devices Central Processing Unit Memory Output Devices

Computing units of measure: 

Computing units of measure Bit – unit piece of information 0 or 1 True or False On or Off Byte – 8 bits _ _ _ _ _ _ _ _ : there are 256 ways to fill in the blanks 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 … 1 1 1 1 1 1 1 1 Kilobyte = 210 bytes = 213 bits Megabyte = 210 Kilobytes = 220 bytes Gigabyte = 210 Megabytes = 220 Kilobytes = 230 bytes Terabyte = 210 Gigabytes = 240 bytes = 243 bits Number of atoms in the universe ~ 2665

Famous numbers: 

Famous numbers 1 1.0 2 3 6 or 7 24 70 911 1067 e ^ e ^ e ^ 79 Yuck oo Loneliest number Odds there will be a pop quiz on the day you skip Number to tango Smallest size of a crowd Peas per pod Willy May's uniform number Smallest weird number Emergency number Archimedes's estimate of the size of the universe Littlewood's number Graham's number How long it takes a watched pot to boil "You, too, can make up your own very large numbers and give them strange names. Try it. It has a certain charm, especially if you happen to be nine." -Carl Sagan, Cosmos 2 2 64 65 3 3 < g < 3

Where did Google get its name: 

Where did Google get its name googol = 10100 googolplex = 10googol

Computer Organization: 

Computer Organization How does it work? Input Devices Central Processing Unit Memory Output Devices

Programming: 

Programming Problem solving through the use of a computer system Maxim You cannot make a computer do something if you do not know how to do it yourself

Programs and algorithms: 

Programs and algorithms Program Algorithmic sequence of instruction that tells a computer what to do Execution Performing the instruction sequence Algorithm Step-by-step problem solving procedure that always completes Well understood Finite size Finite time

Algorithm?: 

Algorithm?

Algorithm?: 

Algorithm?

Algorithm?: 

Algorithm?

Algorithm?: 

Algorithm?

Algorithm?: 

Algorithm?

Algorithm?: 

Algorithm?

Software: 

Software Programming language Language for giving instructions to a computer Why not just do it in English? Major flavors Machine language or object code Assembly language High-level Symbolic language for coding machine language instructions Detailed knowledge of the machine is not required. Uses a vocabulary and structure closer to the problem being solved Java is a high-level programming language Program to which computer can respond directly. Each instruction is a binary code that corresponds to a native instruction

How we got to Java: 

How we got to Java Ada Lovelace (1833) Programmed Babbage’s (daddy) analytical engine ENIAC (1945) Programmed by plugging wires Binary 100100010101001010101010 Assembly (1948) Fortran (1954) John Backus Flow-Matic (1955) Grace Hopper ALGOL (1958) John Backus C (1972) Brian Kernighan Dennis Ritchie C++ (1985) Bjarne Stroustrup Java (1991) James Gosling

Translation: 

Translation Translator Accepts a program written in a source language and translates it to a program in a target language Compiler Standard name for a translator whose source language is a high-level language Interpreter A translator that both translates and executes a source program

Java translation: 

Java translation Two-step process First step Translation from Java to bytecodes Bytecodes are architecturally neutral object code Bytecodes are stored in a file with extension .class Second step An interpreter translates the bytecodes into machine instructions and executes them Interpreter is known a Java Virtual Machine or JVM

Programming Task: 

Programming Task Display a quotation The future belongs to those who believe in the beauty of their dreams. Eleanor Roosevelt

DisplayQuote.java: 

// Authors: J. P. Cohoon and J. W. Davidson // Purpose: display a quotation in a console window public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java

DisplayQuote.java: 

// Authors: J. P. Cohoon and J. W. Davidson // Purpose: display a quotation in a console window public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java

Sample output: 

Sample output

JCreator IDE: 

JCreator IDE

JCreator IDE – compilation or building: 

JCreator IDE – compilation or building

JCreator IDE – execution : 

JCreator IDE – execution

JCreator IDE: 

JCreator IDE

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Keywords – reserved for special usages

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Keywords – reserved for special usages

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Comments – program heading

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Comments – method header

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Semicolons – terminators

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Identifiers – names DisplayQuote – name of class (matches file name)

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Identifiers – names System – standard Java class that supports basic tasks

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Identifiers – names System.out – System provided resource for printing

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Identifiers – names System.out.print – prints strings of characters

DisplayQuote.java: 

// Purpose: display a quotation in a console window // Author: J. P. Cohoon public class DisplayQuote { // method main(): application entry point public static void main(String[] args) { System.out.print("The future belongs to those who"); System.out.println(" believe in the beauty of their"); System.out.println("dreams. Eleanor Roosevelt"); } } DisplayQuote.java Identifiers – names System.out.print – prints strings of characters and ends line

Experiments: 

Experiments How do we do the following? I will do good in my classes. You will do good in your classes. It was a dark and stormy night; the rain fell in torrents--except at occasional intervals, when it was checked by a violent gust of wind which swept up the streets (for it is in London that our scene lies), rattling along the housetops, and fiercely agitating the scanty flame of the lamps that struggled against the darkness. I'll do good in my classes. "You will do good in your classes," said Dana.

You: 

You