- 1 - public class TabelaOrdenada { /** Creates a new instance of TabelaOrdenada */ public TabelaOrdenada() { }

Size: px
Start display at page:

Download "- 1 - public class TabelaOrdenada { /** Creates a new instance of TabelaOrdenada */ public TabelaOrdenada() { }"

Transcription

1 public class TabelaOrdenada { /** Creates a new instance of TabelaOrdenada */ public TabelaOrdenada() { public boolean getordenada(int [] tabela){ boolean teste = true; int i=0; for (int i=0;i<tabela.length;i++) ou while ((teste) && (i<tabela.length-1)){ if (tabela[i+1]>=tabela[i]) teste = tabela[i+1]>=tabela[i]; return false; return true; return teste; public int [] getvalorespares(int [] tabela){ int [] x= new int[100]; int k=0; for (int i=0;i<tabela.length;i++){ if ((tabela[i]%2)==0){ x[k]=tabela[i]; k++; return x; public int somaintervalo(int x, int y, int [] tabela){ int soma = 0; if (x>y){ int aux = x; x=y; y=aux; for (int i=x; i<y;i++) soma += tabela[i]; return soma; public String tostring(int [] tabela){ String s =""; for (int i=0;i<tabela.length;i++) s += tabela[i]; public class TesteTeste { /** Creates a new instance of TesteTeste */ public TesteTeste() { /** args the command line arguments */ public static void main(string[] args) { int [] x = {1,2,3,4,0,6,7,8,9; TabelaOrdenada t = new TabelaOrdenada(); System.out.println("Tabela ordenada? "+t.getordenada(x)); System.out.println("Tabela Par : "+t.tostring(t.getvalorespares(x))); System.out.println("Soma valores 2-5 : "+t.somaintervalo(5,2,x)); public class EquipaFutSal { - 1 -

2 /** Creates a new instance of EquipaFutSal */ public EquipaFutSal() { nomeequipa = ""; numerovitorias=0; numeroempates=0; numeroderrotas=0; golosmarcados=0; golossofridos=0; pontos=0; public EquipaFutSal(String nequipa) { nomeequipa = nequipa; numerovitorias=0; numeroempates=0; numeroderrotas=0; golosmarcados=0; golossofridos=0; pontos=0; String nomeequipa; int numerovitorias; int numeroempates; int numeroderrotas; int golosmarcados; int golossofridos; int pontos; public String getnomeequipa(){ return nomeequipa; public int getpontos(){ return pontos; public int getnumerojogos(){ return (numerovitorias+numeroempates+numeroderrotas); public int getdiferencagmgs(){ return (golosmarcados -golossofridos); public void setpontos(int p){ pontos += p; public void setnumerovitorias(){ numerovitorias++; public void setnumeroempates(){ numeroempates++; public void setnumeroderrotas(){ numeroderrotas++; public void setgolosmarcados(int golos){ golosmarcados += golos; public void setgolossofridos(int golos){ golossofridos += golos; public String tostring(){ String s=""; s = nomeequipa +" "+ "\t" + this.getpontos()+ " " + this.getnumerojogos()+ " " + + numerovitorias + " " + numeroempates + " " + numeroderrotas + " " + + golosmarcados + " " + golossofridos + "\n"; - 2 -

3 import java.util.vector; import java.io.*; public class GestaoFutSal { /** Creates a new instance of GestaoFutSal */ public GestaoFutSal() { Vector t = new Vector(); public void addequipa(string nequipa){ t.addelement(new EquipaFutSal(nequipa)); public void actualizavitoriaa(equipafutsal A, int golosa, EquipaFutSal B, int golosb){ A.setPontos(3); A.setNumeroVitorias(); B.setNumeroDerrotas(); A.setGolosMarcados(golosA); A.setGolosSofridos(golosB); B.setGolosMarcados(golosB); B.setGolosSofridos(golosA); public void actualizaempate(equipafutsal A, EquipaFutSal B, int golos){ A.setNumeroEmpates(); B.setNumeroEmpates(); A.setPontos(1); B.setPontos(1); A.setGolosMarcados(golos); A.setGolosSofridos(golos); B.setGolosMarcados(golos); B.setGolosSofridos(golos); public void resultado(string equipaa, int resultadoa, String equipab, int resultadob){ EquipaFutSal xa = new EquipaFutSal(); EquipaFutSal xb = new EquipaFutSal(); if (equipaa.comparetoignorecase(x.getnomeequipa())==0) xa=(equipafutsal)t.elementat(i); if (equipab.comparetoignorecase(x.getnomeequipa())==0) xb=(equipafutsal)t.elementat(i); if (resultadoa > resultadob) actualizavitoriaa(xa, resultadoa, xb, resultadob); else if (resultadoa < resultadob) actualizavitoriaa(xb, resultadob, xa, resultadoa); else actualizaempate(xa, xb, resultadoa); public void ordena(){ EquipaFutSal xa = new EquipaFutSal(); EquipaFutSal xb = new EquipaFutSal(); for (int i=0;i<t.size()-1;i++){ xa = (EquipaFutSal)t.elementAt(i); for (int j=i+1;j<t.size();j++){ xb = (EquipaFutSal)t.elementAt(j); if (xa.getpontos()<xb.getpontos()){ t.setelementat(xb,i); t.setelementat(xa,j); - 3 -

4 public String getequipacommaispontos(){ int maior=-1; if (x.getpontos()>maior){ maior = x.getpontos(); s = x.getnomeequipa(); public String getequipadifgolosmarcadossofridos(){ int maior=-1; if (x.getdiferencagmgs()>maior){ maior = x.getdiferencagmgs(); s = x.getnomeequipa(); public int getnumeropontosdeequipa(string equipa){ int pontos=0, i=0; boolean encontrou = false; while ((!encontrou) (i<t.size())){ // Mais simples fazer com ciclo for terminar e caso encontrar return getpontos() if (equipa.comparetoignorecase(x.getnomeequipa())==0){ encontrou = true; pontos = x.getpontos(); return pontos; public void soassimequelavamos(string nomedaequipa){ int pontos=0, i=0, maiorpontos; maiorpontos = this.getnumeropontosdeequipa(this.getequipacommaispontos()); boolean encontrou = false; while ((!encontrou) (i<t.size())){ // Mais simples fazer com ciclo for terminar e caso encontrar return getpontos() if (nomedaequipa.comparetoignorecase(x.getnomeequipa())==0){ encontrou = true; x.setpontos(maiorpontos); public String classificacao(){ s += (i+1) + " " + x.tostring(); - 4 -

5 public void guardaficheiro(){ try { BufferedWriter bout = new BufferedWriter(new FileWriter("classificacao.dat")); bout.write(this.classificacao()); bout.close(); catch(ioexception e) { System.out.println(e.getMessage()); public class TesteFutSal { /** Creates a new instance of TesteFutSal */ public TesteFutSal() { /** args the command line arguments */ public static void main(string[] args) { GestaoFutSal x = new GestaoFutSal(); x.addequipa("benfica"); x.addequipa("porto"); x.addequipa("boavista"); x.resultado("benfica", 3, "Boavista", 1); x.resultado("boavista", 3, "Porto",2); x.resultado("porto", 0, "Benfica", 5); System.out.println("Equipa com mais pontos : "+x.getequipacommaispontos()); System.out.println("Equipa com maior diferença de GM e GS : "+x.getequipadifgolosmarcadossofridos()); System.out.println("Pontos do Benfica : "+x.getnumeropontosdeequipa("benfica")); System.out.println("Pontos do Boavista : "+x.getnumeropontosdeequipa("boavista")); System.out.println("Pontos do Porto : "+x.getnumeropontosdeequipa("porto")); x.ordena(); System.out.println(""+x.classificacao()); x.soassimequelavamos("boavista"); x.ordena(); System.out.println(""+x.classificacao()); x.guardaficheiro(); - 5 -

JAVA Program For Processing SMS Messages

JAVA Program For Processing SMS Messages JAVA Program For Processing SMS Messages Krishna Akkulu The paper describes the Java program implemented for the MultiModem GPRS wireless modem. The MultiModem offers standards-based quad-band GSM/GPRS

More information

Communicating with a Barco projector over network. Technical note

Communicating with a Barco projector over network. Technical note Communicating with a Barco projector over network Technical note MED20080612/00 12/06/2008 Barco nv Media & Entertainment Division Noordlaan 5, B-8520 Kuurne Phone: +32 56.36.89.70 Fax: +32 56.36.883.86

More information

- ' +. /0 ( 1 +. ' &+. /"0 &1,

- ' +. /0 ( 1 +. ' &+. /0 &1, !"# $% &'()*++, - ' +. /0 ( 1 +. ' &+. /"0 &1,, +. 2"! public class Essai static public void main(string[] args) System.out.println("Un essai..."); System.out.println(un_calcul.somme(4,5));! 34/0- public

More information

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

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

// Basic node stored in unbalanced binary search trees // Note that this class is not accessible outside // of this package.

// Basic node stored in unbalanced binary search trees // Note that this class is not accessible outside // of this package. // Basic node stored in unbalanced binary search trees // Note that this class is not accessible outside // of this package. class BinaryNode AnyType element; // The data in the node BinaryNode

More information

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75 Preet raj Core Java and Databases CS4PR Time Allotted: 3 Hours Final Exam: Total Possible Points 75 Q1. What is difference between overloading and overriding? 10 points a) In overloading, there is a relationship

More information

Contents. 9-1 Copyright (c) 1999-2004 N. Afshartous

Contents. 9-1 Copyright (c) 1999-2004 N. Afshartous Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to

More information

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

public static void main(string[] args) { System.out.println(hello, world); } } Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static

More information

JAVA NOTES DATA STRUCTURES AND ALGORITHMS

JAVA NOTES DATA STRUCTURES AND ALGORITHMS 15 JAVA NOTES DATA STRUCTURES AND ALGORITHMS Terry Marris July 2001 3 LINEAR SEARCH 3.1 LEARNING OUTCOMES By the end of this lesson the student should be able to describe how a linear search algorithm

More information

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

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement CompSci 125 Lecture 08 Chapter 5: Conditional Statements Chapter 4: return Statement Homework Update HW3 Due 9/20 HW4 Due 9/27 Exam-1 10/2 Programming Assignment Update p1: Traffic Applet due Sept 21 (Submit

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Programs and Methods Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Programs and Methods 1 / 8 The Anatomy of a Java Program It is customary

More information

Collections.sort(population); // Método de ordenamiento

Collections.sort(population); // Método de ordenamiento import java.util.collections; import java.util.linkedlist; import java.util.random; public class GeneticAlgorithms static long BEGIN; static final boolean _DEBUG = true; LinkedList population

More information

Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.

Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. JAVA TYPES BASIC DATA TYPES GENERAL Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. Based on the data type

More information

Sample CSE8A midterm Multiple Choice (circle one)

Sample CSE8A midterm Multiple Choice (circle one) Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names

More information

Crash Course in Java

Crash Course in Java Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is

More information

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

The following program is aiming to extract from a simple text file an analysis of the content such as: Text Analyser Aim The following program is aiming to extract from a simple text file an analysis of the content such as: Number of printable characters Number of white spaces Number of vowels Number of

More information

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

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O 1 Sending Output to a (Text) File import java.util.scanner; import java.io.*; public class TextFileOutputDemo1 public static void

More information

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

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

COSC 111: Computer Programming I. Dr. Bowen Hui University of Bri>sh Columbia Okanagan

COSC 111: Computer Programming I. Dr. Bowen Hui University of Bri>sh Columbia Okanagan COSC 111: Computer Programming I Dr. Bowen Hui University of Bri>sh Columbia Okanagan 1 Today Review slides from week 2 Review another example with classes and objects Review classes in A1 2 Discussion

More information

Creating a Simple, Multithreaded Chat System with Java

Creating a Simple, Multithreaded Chat System with Java Creating a Simple, Multithreaded Chat System with Java Introduction by George Crawford III In this edition of Objective Viewpoint, you will learn how to develop a simple chat system. The program will demonstrate

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Lab 3: Strings & Conditional Statements 20 January 2016 SP1-Lab3.ppt Tobi Brodie (Tobi@dcs.bbk.ac.uk) 1 Lab Objectives This session we are concentrating on Strings and conditional

More information

Chapter Four: DFA Applications. Formal Language, chapter 4, slide 1

Chapter Four: DFA Applications. Formal Language, chapter 4, slide 1 Chapter Four: DFA Applications Formal Language, chapter 4, slide 1 1 We have seen how DFAs can be used to define formal languages. In addition to this formal use, DFAs have practical applications. DFAbased

More information

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following: In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our

More information

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

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

How to Install Java onto your system

How to Install Java onto your system How to Install Java onto your system 1. In your browser enter the URL: Java SE 2. Choose: Java SE Downloads Java Platform (JDK) 7 jdk-7- windows-i586.exe. 3. Accept the License Agreement and choose the

More information

CS 121 Intro to Programming:Java - Lecture 11 Announcements

CS 121 Intro to Programming:Java - Lecture 11 Announcements CS 121 Intro to Programming:Java - Lecture 11 Announcements Next Owl assignment up, due Friday (it s short!) Programming assignment due next Monday morning Preregistration advice: More computing? Take

More information

Patterns for Java Program Testing

Patterns for Java Program Testing Patterns for Java Program Testing Marco Torchiano Department of Computer and Information Science (IDI), Norwegian University of Science and Technology (NTNU), N-7491 Trondheim, Norway. Tel. +47 735 94489,

More information

ASSIGNMENT 4 Strings, Classes, Methods, and Numbers

ASSIGNMENT 4 Strings, Classes, Methods, and Numbers ASSIGNMENT 4 Strings, Classes, Methods, and Numbers COMP-202B, Winter 2009, All Sections Due: Tuesday, March 31, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified, you

More information

Inheritance, overloading and overriding

Inheritance, overloading and overriding Inheritance, overloading and overriding Recall with inheritance the behavior and data associated with the child classes are always an extension of the behavior and data associated with the parent class

More information

Software Engineering 1 EEL5881 Spring 2009. Homework - 2

Software Engineering 1 EEL5881 Spring 2009. Homework - 2 Software Engineering 1 EEL5881 Spring 2009 Homework - 2 Submitted by Meenakshi Lakshmikanthan 04/01/2009 PROBLEM STATEMENT: Implement the classes as shown in the following diagram. You can use any programming

More information

Programmation Orientée Objets. et langage Java

Programmation Orientée Objets. et langage Java Programmation Orientée Objets et langage Java Programmation procédurale Construire(Maison m){ creuser(fouilles); commander(béton) couler(fouilles); commander(parpaings); while(!fini(sous-sol)){poser(parpaings);

More information

1.00 Lecture 23. Streams

1.00 Lecture 23. Streams 1.00 Lecture 23 Input/Output Introduction to Streams Exceptions Reading for next time: Big Java 19.3-19.4 Streams Java can communicate with the outside world using streams Picture a pipe feeding data into

More information

Topic 11 Scanner object, conditional execution

Topic 11 Scanner object, conditional execution Topic 11 Scanner object, conditional execution "There are only two kinds of programming languages: those people always [complain] about and those nobody uses." Bjarne Stroustroup, creator of C++ Copyright

More information

Chapter 2 Introduction to Java programming

Chapter 2 Introduction to Java programming Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break

More information

!"# $ %!&' # &! ())*!$

!# $ %!&' # &! ())*!$ !"# $ %!&' # &! ())*!$ !" #!$ %& ' ( ) * +,--!&"" $.!! /+010!" +!, 31! 4)&/0! $ #"5!! & + 6+ " 5 0 7 /&8-9%& ( +" 5)& /*#.! &( $ 1(" 5 # ( 8 +1 + # + 7$ (+!98 +&%& ( +!" (!+!/ (!-. 5 7 (! 7 1+1( & + ":!

More information

Homework/Program #5 Solutions

Homework/Program #5 Solutions Homework/Program #5 Solutions Problem #1 (20 points) Using the standard Java Scanner class. Look at http://natch3z.blogspot.com/2008/11/read-text-file-using-javautilscanner.html as an exampleof using the

More information

PROJECT: Quiz Game. Java Projects: Quiz Game STEP 1 CREATE A CLASS

PROJECT: Quiz Game. Java Projects: Quiz Game STEP 1 CREATE A CLASS You will need to have covered all of the Java basics tutorials before going any further, please make sure you have completed them all. If you have any questions or get stuck ask a mentor or the person

More information

Section 6 Spring 2013

Section 6 Spring 2013 Print Your Name You may use one page of hand written notes (both sides) and a dictionary. No i-phones, calculators or any other type of non-organic computer. Do not take this exam if you are sick. Once

More information

AP Computer Science Java Subset

AP Computer Science Java Subset APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

More information

public void creditaccount(string accountnumber, float amount) { this.accounts.get(accountnumber).credit(amount); }

public void creditaccount(string accountnumber, float amount) { this.accounts.get(accountnumber).credit(amount); } package bank; //... public class Bank { private Map accounts; public Bank() { this.accounts = new HashMap(); public void addaccount(bankaccount account) { this.accounts.put(account.getnumber(),

More information

AP Computer Science II Java Unit Lab Assignment # 26b

AP Computer Science II Java Unit Lab Assignment # 26b AP Computer Science II Java Unit Lab Assignment # 26b The "Knight's Tour" Program 90 & 100 Point Versions Assignment Purpose: The purpose of this assignment is to review and practice Java program coding

More information

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius Programming Concepts Practice Test 1 1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius 2) Consider the following statement: System.out.println("1

More information

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays. Arrays Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html 1 Grid in Assignment 2 How do you represent the state

More information

Question1-part2 What undesirable consequences might there be in having too long a DNS cache entry lifetime?

Question1-part2 What undesirable consequences might there be in having too long a DNS cache entry lifetime? CSCI 312 - DATA COMMUNICATIONS AND NETWORKS FALL, 2014 Assignment 4 Working as a group. Working in small gruops of 2-4 students. When you work as a group, you have to return only one home assignment per

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty("java.security.policy","../server.java.

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty(java.security.policy,../server.java. ExempleRMI.java import java.lang.*; import java.rmi.registry.*; import java.rmi.server.*; import java.io.*; import java.util.*; ExempleRMI.java import pkgexemple.*; public class ExempleRMI public static

More information

Program errors and exception handling

Program errors and exception handling Unit 10 Program errors and exception handling Summary Types of program errors Syntax, semantic, and logical errors Compile time and runtime errors Test drivers Debugging techniques Exception handling The

More information

Computing Science 114 Solutions to Final Examination Tuesday December 14, 2004

Computing Science 114 Solutions to Final Examination Tuesday December 14, 2004 Computing Science 114 Solutions to Final Examination Tuesday December 14, 2004 INSTRUCTOR: I. E. LEONARD TIME: 3 HOURS Question 1. [10 = 5 + 5 pts] An operator is said to be overloaded when it is used

More information

Installing Java (Windows) and Writing your First Program

Installing Java (Windows) and Writing your First Program Appendix Installing Java (Windows) and Writing your First Program We will be running Java from the command line and writing Java code in Notepad++ (or similar). The first step is to ensure you have installed

More information

file://c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html

file://c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html file:c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html Seite 1 von 5 ScanCmds.java ------------------------------------------------------------------------------- ScanCmds Demontration

More information

3 length + 23 size = 2

3 length + 23 size = 2 This pledged exam is closed textbook, open class web site, and two pieces of paper with notes. You may not access any other code or websites including your own. Write your email id and name on every page

More information

COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 Term Test #2 COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005 Family Name: Given Name(s): Student Number: Question Out of Mark A Total 16 B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 C-1 4

More information

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

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4 JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4 NOTE: SUN ONE Studio is almost identical with NetBeans. NetBeans is open source and can be downloaded from www.netbeans.org. I

More information

Intel Retail Client Manager Audience Analytics

Intel Retail Client Manager Audience Analytics Intel Retail Client Manager Audience Analytics By using this document, in addition to any agreements you have with Intel, you accept the terms set forth below. You may not use or facilitate the use of

More information

CS170 Lab 11 Abstract Data Types & Objects

CS170 Lab 11 Abstract Data Types & Objects CS170 Lab 11 Abstract Data Types & Objects Introduction: Abstract Data Type (ADT) An abstract data type is commonly known as a class of objects An abstract data type in a program is used to represent (the

More information

Project 4 DB A Simple database program

Project 4 DB A Simple database program Project 4 DB A Simple database program Due Date April (Friday) Before Starting the Project Read this entire project description before starting Learning Objectives After completing this project you should

More information

B.Sc (Honours) - Software Development

B.Sc (Honours) - Software Development Galway-Mayo Institute of Technology B.Sc (Honours) - Software Development E-Commerce Development Technologies II Lab Session Using the Java URLConnection Class The purpose of this lab session is to: (i)

More information

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

Chulalongkorn University International School of Engineering Department of Computer Engineering 2140105 Computer Programming Lab. Chulalongkorn University Name International School of Engineering Student ID Department of Computer Engineering Station No. 2140105 Computer Programming Lab. Date Lab 2 Using Java API documents, command

More information

Software Development with UML and Java 2 SDJ I2, Spring 2010

Software Development with UML and Java 2 SDJ I2, Spring 2010 Software Development with UML and Java 2 SDJ I2, Spring 2010 Agenda week 7, 2010 Pakages Looking back Looking forward Packages Interfaces Page 1 Spring 2010 Download, Install/Setup 1. Java SE SDK (http://java.sun.com/javase/downloads)

More information

Chapter 6 Load Balancing

Chapter 6 Load Balancing Chapter 6 Load Balancing Part I. Preliminaries Part II. Tightly Coupled Multicore Chapter 2. Parallel Loops Chapter 3. Parallel Loop Schedules Chapter 4. Parallel Reduction Chapter 5. Reduction Variables

More information

(Eng. Hayam Reda Seireg) Sheet Java

(Eng. Hayam Reda Seireg) Sheet Java (Eng. Hayam Reda Seireg) Sheet Java 1. Write a program to compute the area and circumference of a rectangle 3 inche wide by 5 inches long. What changes must be made to the program so it works for a rectangle

More information

Java Review (Essentials of Java for Hadoop)

Java Review (Essentials of Java for Hadoop) Java Review (Essentials of Java for Hadoop) Have You Joined Our LinkedIn Group? What is Java? Java JRE - Java is not just a programming language but it is a complete platform for object oriented programming.

More information

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

More information

Reading a Text File. Reading and Writing Text Files Exceptions. Testing for more input. Example: Count Words

Reading a Text File. Reading and Writing Text Files Exceptions. Testing for more input. Example: Count Words Reading a Text File Reading and Writing Text Files Exceptions 15-121 Fall 2010 Margaret Reid-Miller A Scanner object can be connected to many input sources: keyboard, file, network, string To read a text

More information

Network/Socket Programming in Java. Rajkumar Buyya

Network/Socket Programming in Java. Rajkumar Buyya Network/Socket Programming in Java Rajkumar Buyya Elements of C-S Computing a client, a server, and network Client Request Result Network Server Client machine Server machine java.net Used to manage: URL

More information

Java 101 primer: Composition and inheritance. Use composition to overcome the problem with inheritance

Java 101 primer: Composition and inheritance. Use composition to overcome the problem with inheritance Java 101 primer: Composition and inheritance Use composition to overcome the problem with inheritance BY JEFF FRIESEN, JAVAWORLD, OCTOBER 2015 In Java 101: Inheritance in Java, Part 1, you learned how

More information

Java Memory Management

Java Memory Management Java Memory Management 1 Tracing program execution Trace: To follow the course or trail of. When you need to find and fix a bug or have to understand a tricky piece of code that your coworker wrote, you

More information

CS 112/ Section 02 Hilal Ünal Aslıhan Ekim Merve Özkılınç Notes of March 11, 2008 and March 13, 2008: Pig Latin: add adday. main.

CS 112/ Section 02 Hilal Ünal Aslıhan Ekim Merve Özkılınç Notes of March 11, 2008 and March 13, 2008: Pig Latin: add adday. main. CS 112/ Section 02 Hilal Ünal Aslıhan Ekim Merve Özkılınç Notes of March 11, 2008 and March 13, 2008: Pig Latin: happy appyhay want antway add adday two consonants: the ethay main translate translateword

More information

Overview of Web Services API

Overview of Web Services API 1 CHAPTER The Cisco IP Interoperability and Collaboration System (IPICS) 4.5(x) application programming interface (API) provides a web services-based API that enables the management and control of various

More information

Java Crash Course Part I

Java Crash Course Part I Java Crash Course Part I School of Business and Economics Institute of Information Systems HU-Berlin WS 2005 Sebastian Kolbe skolbe@wiwi.hu-berlin.de Overview (Short) introduction to the environment Linux

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

java Features Version April 19, 2013 by Thorsten Kracht

java Features Version April 19, 2013 by Thorsten Kracht java Features Version April 19, 2013 by Thorsten Kracht Contents 1 Introduction 2 1.1 Hello World................................................ 2 2 Variables, Types 3 3 Input/Output 4 3.1 Standard I/O................................................

More information

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from www.agileskills.org

Licensed for viewing only. Printing is prohibited. For hard copies, please purchase from www.agileskills.org Unit Test 301 CHAPTER 12Unit Test Unit test Suppose that you are writing a CourseCatalog class to record the information of some courses: class CourseCatalog { CourseCatalog() { void add(course course)

More information

C:\Documents and Settings\Gijs\Desktop\src\client\Client.java dinsdag 3 november 2009 10:50

C:\Documents and Settings\Gijs\Desktop\src\client\Client.java dinsdag 3 november 2009 10:50 C:\Documents and Settings\Gijs\Desktop\src\client\Client.java dinsdag 3 november 2009 10:50 package client; import hotel.bookingconstraints; import hotel.bookingexception; import hotel.costumersessionremote;

More information

Programming Assignment: Development of a Proxy Cache

Programming Assignment: Development of a Proxy Cache Programming Assignment: Development of a Proxy Cache La prova avrà una valutazione da 0 a 3 punti da aggiungere alla media dell esito delle due prove di esonero scritte. La gestione dei thread non è da

More information

Projet Java. Responsables: Ocan Sankur, Guillaume Scerri (LSV, ENS Cachan)

Projet Java. Responsables: Ocan Sankur, Guillaume Scerri (LSV, ENS Cachan) Projet Java Responsables: Ocan Sankur, Guillaume Scerri (LSV, ENS Cachan) Objectives - Apprendre à programmer en Java - Travailler à plusieurs sur un gros projet qui a plusieurs aspects: graphisme, interface

More information

Java from a C perspective. Plan

Java from a C perspective. Plan Java from a C perspective Cristian Bogdan 2D2052/ingint04 Plan Objectives and Book Packages and Classes Types and memory allocation Syntax and C-like Statements Object Orientation (minimal intro) Exceptions,

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 4 Lecture 4-1: Scanner; if/else reading: 3.3 3.4, 4.1 Interactive Programs with Scanner reading: 3.3-3.4 1 Interactive programs We have written programs that print console

More information

Object-Oriented Programming in Java

Object-Oriented Programming in Java CSCI/CMPE 3326 Object-Oriented Programming in Java Class, object, member field and method, final constant, format specifier, file I/O Dongchul Kim Department of Computer Science University of Texas Rio

More information

Inside the Java Virtual Machine

Inside the Java Virtual Machine CS1Bh Practical 2 Inside the Java Virtual Machine This is an individual practical exercise which requires you to submit some files electronically. A system which measures software similarity will be used

More information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

public class demo1swing extends JFrame implements ActionListener{

public class demo1swing extends JFrame implements ActionListener{ import java.io.*; import java.net.*; import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class demo1swing extends JFrame implements ActionListener JButton demodulacion;

More information

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

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description

More information

ADDING SOUND TO JAVA APPLICATIONS

ADDING SOUND TO JAVA APPLICATIONS ADDING SOUND TO JAVA APPLICATIONS It s now time to add sound effects to our programs. Fortunately, Java provides built-in support for playing sound and music files. Java supports a variety of audio formats,

More information

Java Program Coding Standards 4002-217-9 Programming for Information Technology

Java Program Coding Standards 4002-217-9 Programming for Information Technology Java Program Coding Standards 4002-217-9 Programming for Information Technology Coding Standards: You are expected to follow the standards listed in this document when producing code for this class. Whether

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Introduction: Abstract Data Types and Java Review

Introduction: Abstract Data Types and Java Review Introduction: Abstract Data Types and Java Review Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Welcome to Computer Science E-119! We will study fundamental data structures.

More information

PROGRAMMING REFRESHER MODULE. Delivered by Ana Cavalcanti and Alvaro Miyazawa Prepared by Dr Lilian Blot

PROGRAMMING REFRESHER MODULE. Delivered by Ana Cavalcanti and Alvaro Miyazawa Prepared by Dr Lilian Blot PROGRAMMING REFRESHER MODULE Delivered by Ana Cavalcanti and Alvaro Miyazawa Prepared by Dr Lilian Blot The Rules Everything in PREF (Week 1) is optional. From week 2 of APRC and JAPC, we assume that all

More information

Java : Data types, Identifiers and Operators. Instructor: Nihshanka Debroy

Java : Data types, Identifiers and Operators. Instructor: Nihshanka Debroy Java : Data types, Identifiers and Operators Instructor: Nihshanka Debroy Java Programs Can use a text editor to type out Java code Save as a file with.java extension (Example: HelloWorld.java) File contains

More information

CSE 143 Lecture 20. Binary Search Trees. read slides created by Marty Stepp

CSE 143 Lecture 20. Binary Search Trees. read slides created by Marty Stepp CSE 143 Lecture 20 Binary Search Trees read 17.3 slides created by Marty Stepp http://www.cs.washington.edu/143/ Binary search trees binary search tree ("BST"): a binary tree that is either: empty (null),

More information

Table of Contents. LESSON: CASE Document Library...1

Table of Contents. LESSON: CASE Document Library...1 Table of Contents LESSON: CASE Document Library...1 Case Description...2 LABS...2 1. Creating the Document Class...2 2. Adding another constructor to Document class...2 3. Object Oriented Programming...2

More information

WRITING DATA TO A BINARY FILE

WRITING DATA TO A BINARY FILE WRITING DATA TO A BINARY FILE TEXT FILES VS. BINARY FILES Up to now, we have looked at how to write and read characters to and from a text file. Text files are files that contain sequences of characters.

More information

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

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

Quick Introduction to Java

Quick Introduction to Java Quick Introduction to Java Dr. Chris Bourke Department of Computer Science & Engineering University of Nebraska Lincoln Lincoln, NE 68588, USA Email: cbourke@cse.unl.edu 2015/10/30 20:02:28 Abstract These

More information

TCP Sockets. Multithreading. But first... Overview of Multithreading in Java. Background on Threads

TCP Sockets. Multithreading. But first... Overview of Multithreading in Java. Background on Threads But first... Background on Threads Overview of Multithreading in Java Multithreading Java has build-in support for concurrent programming. This enables you to have multiple flows of control, represented

More information

The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)

The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits) Binary I/O streams (ascii, 8 bits) InputStream OutputStream The Java I/O System The decorator design pattern Character I/O streams (Unicode, 16 bits) Reader Writer Comparing Binary I/O to Character I/O

More information

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

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java

More information

CSE 308. Coding Conventions. Reference

CSE 308. Coding Conventions. Reference CSE 308 Coding Conventions Reference Java Coding Conventions googlestyleguide.googlecode.com/svn/trunk/javaguide.html Java Naming Conventions www.ibm.com/developerworks/library/ws-tipnamingconv.html 2

More information

Assignment 4 Solutions

Assignment 4 Solutions CSCI 312 - DATA COMMUNICATIONS AND NETWORKS FALL, 2014 Assignment 4 Solutions Working as a pair Working in pairs. When you work as a pair you have to return only one home assignment per pair on a round.

More information

MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION

MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION 1. Write a loop that computes (No need to write a complete program) 100 1 99 2 98 3 97... 4 3 98 2 99 1 100 Note: this is not the only solution; double sum

More information