Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Java Programming: Week 1 - Algorithm Design and Object Oriented Paradigm in Java - Prof. N, Lab Reports of Computer Science

The goals, guidelines, and student responsibilities for the first week of the mat2170 course focused on algorithm design and object oriented paradigm using java. Topics include java basics, the mathcs lab, and the compilation process.

Typology: Lab Reports

Pre 2010

Uploaded on 07/28/2009

koofers-user-zoq-1
koofers-user-zoq-1 🇺🇸

10 documents

1 / 37

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Mat 2170
WEEK 1
Nancy Van Cleave
Fall 2007
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Partial preview of the text

Download Java Programming: Week 1 - Algorithm Design and Object Oriented Paradigm in Java - Prof. N and more Lab Reports Computer Science in PDF only on Docsity!

Mat 2170

WEEK 1

Nancy Van Cleave

Fall 2007

Mat2170 Course Goals

I (^) Algorithm Design

I (^) Object Oriented Paradigm

I (^) Syntax of Java language

I (^) Critical Thinking Skills

Week 1 Student Responsibilities

I (^) Reading : Textbook, Chapters 1 and 2.

I (^) Lab : Lab 1, Prelab, & Postlab

I (^) Homework : Hwk 1

I (^) Attendance

Week One Topics

I (^) What is Computer Science?

I (^) Computer Hardware

I (^) Algorithms

I (^) The Programming Process

I (^) Java

I (^) The mathcs lab

I Hello World Program

Components of a Typical Computer

CPU

memory

secondary storage I/O devices

network

bus

............... ................. ............... ................. ............... ................. ............... ................. ............... ................. ............... ................. ............... ................. ................ ............... ................. ............... ................. ................ ................

Computer Hardware

I (^) CPU ( Central Processing Unit ) - an integrated circuit on a silicon chip; computations, coordinates computer activities

I (^) Memory ( Primary Storage ) - usually a special integrated-circuit chip called a RAM , or random-access memory; information lost when machine turned off

I (^) Secondary Storage - hard disk, thumb drive, CDs, diskettes, etc.; permanent data storage

I (^) Input/Output Devices ( I/O devices ) - keyboard, mouse, monitor, printer

I (^) Network - connection to other computers, Internet

The Programming Process

I (^) Algorithmic Design I (^) Specications ñ required I/O, types, restrictions

I (^) Test Suite ñ well-selected inputs with expected outputs I (^) Logic which solves problem (human readable) I (^) General (Outline) I (^) Detailed

I (^) Coding I (^) Translating Detailed algorithm into computer language (JAVA) I (^) Debugging ñ locating and eliminating errors

I (^) Maintenance ñ evolution of program over time

Stages in the ìClassicî Compilation Process

Translating code into machine language

#include <stdio.h> main() {printf("Hello\n"); } compiler

(^01001001010110010001000010100011101011) 0110100111010101100

(^10010110101100010110100100101001011011) 0101101011010100101

(^01001001010110010001000010100011101011) (^01101001110101011001001011010110001011) (^01001001010010110110101101011010100101)

source file object file

linker

executable file

files/librariesother object

The Interpreter Process

Translating code into a machineñindependent intermediate language

I (^) An interpreter for any given machine architecture translates source code into an intermediate language on that machine.

I (^) The interpreter simulates instructions by performing operations that have the same effect.

I (^) No separate executable le is produced ó the interpreter translates and executes at the same time.

Java & a Hybrid Strategy

Java combines the functions of a compiler and an interpreter

I (^) Initial compilation phase : translates program into a common intermediate language, independent of underlying hardware.

I (^) The intermediate code is stored in les called: class les.

I (^) Class les are combined with other class les and libraries to produce a complete version of the intermediate program with everything it needs linked together.

I (^) Usual format for the resulting program is a compressed collection of individual les called a JAR archive.

Stages in Running a Java Program

compilerJava

Machine^ VirtualJava

CA FE BA BE 00 03 0000 16 07 00 1A 07 00 00 04 00 07 0C 00 1301 00 16 28 4C 6A 6147 72 61 70 68 69 63 CA^000001 FE BA16 0704 0000 16^ BE^000728 00 1A0C4C^030700 6A^00001361 47 72 61 70 68 69 63

import acm.program.*;

}

public class Add2 ext

}

int n1 = readInt("Entprintln("This progr

public void run() { int n2 = readInt("Entint total = n1 + n2; println("The total is

2D 1400 00 1F0A 0018 0C 080200 000017 0F 0800 07 0A1C

class file

files/libraries

Java source file

other class

linker

JAR archive

14 0A 00 02 00 08 0A2D 00 1F 08 00 0F 0700 18 0C 00 17 00 1C

What you'll need in lab to program in Java:

  1. An account on the mathcs server, issued in class
  2. Your EIU email userid and password , obtained from ITS
  3. A terminal window , from which we can direct commands to the computer system
  4. The ACM graphics library: acm.jar
  5. A way to create the programs with an editor: netbeans
  6. The java interpreter: JDK
  7. A web browser: refox
  8. A way to transfer les from your account on the mathcs server to your EIU student account: scp , or secure copy

Directory Structure in Linux

created by mkdir

created by netbeans

HelloProgram

dist

HelloProgram.class

classes

build src

HelloProgram.java

lab

HelloProgram.jar

acmLibrary

nkvancleave

Directory Structure in Your EIU Account

HelloProgram.html HelloProgram.jar acmLibrary.jar

http

index.html

nkvancleave