ECE 122. Engineering Problem Solving with Java



Similar documents
First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Pemrograman Dasar. Basic Elements Of Java

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Chapter 2 Introduction to Java programming

Chapter 1 Java Program Design and Development

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

CS 106 Introduction to Computer Science I

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

JavaScript: Control Statements I

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

13 File Output and Input

Install Java Development Kit (JDK) 1.8

Getting Started with the Internet Communications Engine

J a v a Quiz (Unit 3, Test 0 Practice)

Computer Programming Tutorial

Variables, Constants, and Data Types

AP Computer Science Java Subset

Crash Course in Java

Java CPD (I) Frans Coenen Department of Computer Science

Introduction to Java

EE360: Digital Design I Course Syllabus

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

AP Computer Science Java Mr. Clausen Program 9A, 9B

Java Interview Questions and Answers

The C Programming Language course syllabus associate level

Java Programming Language

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

El Dorado Union High School District Educational Services

Introduction to Java. CS 3: Computer Programming in Java

LAB4 Making Classes and Objects

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

PL/SQL MOCK TEST PL/SQL MOCK TEST I

C++ Programming Language

Moving from CS 61A Scheme to CS 61B Java

Sources: On the Web: Slides will be available on:

Chapter 2: Elements of Java

Java Crash Course Part I

Java Basics: Data Types, Variables, and Loops

COS 217: Introduction to Programming Systems

Programming in Java Course Technology, a part of Cengage Learning.

Programming Project 1: Lexical Analyzer (Scanner)

Chapter 2. println Versus print. Formatting Output withprintf. System.out.println for console output. console output. Console Input and Output

Lecture 5: Java Fundamentals III

Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts

Java Programming Fundamentals

Building Java Programs

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Week 2 Practical Objects and Turtles

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

CSE 308. Coding Conventions. Reference

Using Files as Input/Output in Java 5.0 Applications

Comp151. Definitions & Declarations

The programming language C. sws1 1

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

COMP 110 Prasun Dewan 1

EE361: Digital Computer Organization Course Syllabus

C++ INTERVIEW QUESTIONS

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Chapter 3. Input and output. 3.1 The System class

Habanero Extreme Scale Software Research Project

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

Understanding class definitions

PL / SQL Basics. Chapter 3

Computer Programming I

6.1. Example: A Tip Calculator 6-1

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Let s put together a Manual Processor

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

public static void main(string[] args) { System.out.println("hello, world"); } }

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Lecture 12: More on Registers, Multiplexers, Decoders, Comparators and Wot- Nots

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

Example of a Java program

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Week 1: Review of Java Programming Basics

The following program is aiming to extract from a simple text file an analysis of the content such as:

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction

CS 241 Data Organization Coding Standards

Product: DQ Order Manager Release Notes

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

A Comparison of Student Learning in an Introductory Logic Circuits Course: Traditional Face-to-Face vs. Fully Online

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

Software Engineering Techniques

Object Oriented Software Design

Part I. Multiple Choice Questions (2 points each):

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4

Informatica e Sistemi in Tempo Reale

Transcription:

ECE 122 Engineering Problem Solving with Java Introduction to Electrical and Computer Engineering II Lecture 1 Course Overview Welcome! What is this class about? Java programming somewhat software somewhat Solving engineering problems with programming our main focus! What will I get out of this class A better understanding of specifying engineering problems Techniques for specifying engineering problems in Java A good understanding of the fundamentals of Java

Course resources The course web site contains important information associated with the course. Check the site frequently for homework info, assignments, tips, lectures slides, etc. Course web site: http://www.ecs.umass.edu/ece/ece122/ Course text: Java Software Solutions, fourth edition, Lewis and Loftus, Addison-Wesley You will only be responsible for material discussed in lecture and in discussion When in doubt refer to the lecture slides. Course software: DrJava Its free from drjava.org! Course staff Prof. Russell Tessier - lecturer Graduate TAs Deepak Unnikrishnan Ramakrishna Vadlamani Ibis Benito Undergraduate TAs Lukas Root Michael Haines TBD

Grade Composition 3 exams. 20%, 20%, 24% 6 homeworks 2% each 6 labs. 4% each Assignments must be turned in on time! Excuse 1: The server was down not likely Excuse 2: I accidently uploaded the wrong files check programs immediately before submission Excuse 3: My network connection went down make sure assignment is uploaded early ENGIN112/ECE122 Comparison ENGIN112 ECE122 No late assignments Arrive to lecture on time Most information from lecture slides Well dressed Taller

Brief Rehash of ENGIN112: Digital Systems Information can be represented by binary digits 0 and 1 We can build digital systems with logic gates A Y B Groups of gates can perform computation DataA DataB Function ALU Conditions DataOut How do we often solve task-based problems? Example: A trip to the store 1. Get out of bed 2. Get dressed 3. Make list of items 4. Get into car 5. Drive to store 6. Pick items off shelf 7. Go to register 8. Drive home Observations - Activities take place sequentially, one at a time - The order of the operations matter - If the data is the same. I should get the same result every time. Question: How does a computer solve problems?

Datapath I/O A wire can be driven by only one tri-state at a time If InPass is active, AluPass must be inactive If AluPass is active, InPass must be inactive InPass OutPass Out LoadX X Y LoadY Function ALU AluPass Datapath I/O Two values enter from the left (A and B) Need to perform (A+B)+A In -> X (Load A) In -> Y (Load B) Four steps and then repeat A+B -> Y (A+B)+A -> Out InPass OutPass In Out LoadX X Y LoadY Function ALU AluPass

Implementing the Control ROM Two values enter from the left (A and B) Need to perform (A+B)+A In -> X (Load A) - State 00 In -> Y (Load B) - State 01 A+B -> Y - State 10 (A+B)+A -> Out - State 11 Addr PS ROM 0100010100 00 1000001100 01 1101101010 10 0001100011 11 THIS IS SOFTWARE! NS PS NS Function LoadX LoadY InPass AluPass OutPass 00 01 000 1 0 1 0 0 01 10 000 0 1 1 0 0 10 11 011 0 1 0 1 0 11 00 011 0 0 0 1 1 Control outputs Datapath and Control ROM Control of data path with ROM ROM contains program control ROM 011111010 101001001 001001001 current state reg A read register A register B next state reg B read control bits ALU Engin112

What is Programming Language? A programming language allows programmers to specify tasks for the computer one task at a time. Just like most things in life The computer then executes this sequence of tasks on hardware to generate a result For the same data, the computer should get the same result every time. To solve engineering problems we need to: Specify the problem as a series of simple tasks Know how to specify these tasks (syntax, rules, format, tools, etc). Programming language for this semester: Java! Java Program Structure // comments about the class public class MyProgram { class header class body } Comments can be placed almost anywhere

Java Program Structure // comments about the class public class MyProgram { // comments about the method public static void main (String[] args) { } method body method header } Java Program Structure In the Java programming language: A program is made up of one or more classes A class contains one or more methods A method contains program statements These terms will be explored in detail throughout the course A Java application always contains a method called main

A Java Program /* Lewis/Loftus 6/11/2003 */ Lincoln.java demonstrates the basic structure of a Java Application. public class Lincoln { // starts the class definition These are single line comments // Prints a presidential quote. public static void main (String[] args) // this is a method name { System.out.println ( A quote by Abraham Lincoln: ); // invokes another method System.out.println ( Whatever you are, be a good one. ); // invokes another method } } // ends the class definition What to Notice in Lincoln.java The first few lines between /* and */ are comments. Comments don t affect what the program does but are included to make the program easier to understand. Comments included in a program are called inline documentation. The comment symbols /* and */ can surround a multiline comment. The comment symbol // can be used at the beginning of a single-line comment.

Comments Comments are notes in the text of a program to assist that/any programmer who must later modify or simply understand the code. The original programmer often will not remember later the details of the program he or she has written. Comments within the text of a program are referred to as internal documentation. Good internal and external documentation are essential. Two Types of Comments A single-line comment in Java takes the form: // This is a comment. A multi-line comment takes the form: /* */ This is one comment that spans several lines. It is also permissible to use the above notation for a single-line comment. /* This is a comment */

Good Programming Practices Appendix F of our text presents guidelines for good programming practices Specific techniques for documenting programs. Be Verbose You can assume the reader is computer literate and familiar with Java. Assume the reader knows almost nothing about what the program is supposed to do. You won t be able to recognize what your program does after (at most) one week. Identifiers and Reserved Words The words used when writing programs are called identifiers. There are three categories of identifiers: 1. Words that we make up (Lincoln and args) 2. Words that another programmer chose (String, System, out, println, and main). Often these are words that were chosen by a programmer for code that became part of a Java library; Now available for use by all Java programmers. 3. Words that are reserved for special purposes in the language (class, public, static, and void). The designers of the Java language chose these words.

The Reserved Words Reserved words are identifiers that have special meaning in a programming language. In the Lincoln program, they are class, public, static, and void. //******************************************************************** // Lincoln.java Author: Lewis/Loftus // // Demonstrates the basic structure of a Java application. //******************************************************************** public class Lincoln { //----------------------------------------------------------------- // Prints a presidential quote. //----------------------------------------------------------------- public static void main (String[] args) { System.out.println ("A quote by Abraham Lincoln:"); } } System.out.println ("Whatever you are, be a good one."); Reserved Words The Java reserved words these words cannot be used for any other purpose, such as naming a class or method. abstract boolean break byte case catch char class const continue default do double else extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while

White Space Spaces, blank lines, and tabs are called white space White space is used to separate words and symbols in a program Extra white space is ignored A valid Java program can be formatted many ways Programs should be formatted to enhance readability, using consistent indentation Summary Programs are a series of tasks for a computer to perform. A programming language defines how we specify the tasks Important to use many comments and to understand identifiers Reading: L+L: 1.1 1.4, Download and play with DrJava