# Using Two-Dimensional Arrays

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Using Two-Dimensional Arrays Great news! What used to be the old one-floor Java Motel has just been renovated! The new, five-floor Java Hotel features a free continental breakfast and, at absolutely no charge, a free newspaper delivered to your door every morning. That s a 50-cent value, absolutely free! Speaking of things that are continental, the designers of the new Java Hotel took care to number floors the way people do in France. The ground floor (in French, le rez-de-chaussée ) is the zero floor, the floor above that is the first floor, and so on. Figure B-1 shows the newly renovated hotel. Figure B-1: A big, high-rise hotel. You can think of the hotel as an array with two indices -- a two-dimensional array. You declare the array this way. int guests[][] = new int[5][10]; 1

2 The guests array has five rows (numbered 0 to 4, inclusive) and ten columns (numbered 0 to 9, inclusive). To register two guests in Room 9 on the first floor, you write guests[1][9] = 2; TechnicalStuff The people who do serious Java like to think of a two-dimensional array as an array of rows (that is, an array of ordinary one-dimensional arrays). With this thinking, the rows of the guests array (above) are denoted guests[0], guests[1], guests[2], guests[3], and guests[4]. For a picture of all this, refer to Figure B-1. A complete program that uses this guest array is shown in Listing B-1. Listing B-1 An array of arrays import static java.lang.system.out; import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; public class ShowGuests { public static void main(string args[]) throws FileNotFoundException { int guests[][] = new int[5][10]; Scanner myscanner = new Scanner(new File("GuestList")); guests[floor][roomnum] = myscanner.nextint(); for (int floor = 4; floor >= 0; floor--) { out.print("floor " + floor + ":"); out.print(" "); out.print(guests[floor][roomnum]); out.println(); out.println(); out.print("room: "); out.print(" "); 2

3 out.print(roomnum); Figure B-2 shows a run of the code from Listing B-1. The input file, GuestList, looks like the file in Listing 11-1, except that the file for this section s program has 50 lines in it. OnTheWeb You can snare a 50-line GuestList file along with this document s code listings from the book s Web site. Figure B-2: Guest counts. In Listing B-1, notice the primary way you handle a two-dimensional array -- by putting a for loop inside another for loop. For instance, when you read values into the array, you have a room number loop within a floor number loop. Because the roomnum loop is inside the floor loop, the roomnum variable changes faster than the floor variable. In other words, the program prints guest counts for all the rooms on a floor before marching on to the next floor. Remember The outer loop s variable changes slower; the inner loop s variable changes faster. In displaying the hotel s numbers, I could have chosen to start with floor 0 and go up to floor 4. But then the output would have looked like an upsidedown hotel. In the program s output, you want the top floor s numbers to be displayed first. To make this work, I created a loop whose counter goes backwards. for (int floor = 4; floor >= 0; floor--) 3

4 So notice that the loop s counter starts at 4, goes downward each step of the way, and keeps going down until the counter s value is equal to 0. This section does one better on the stuff from earlier sections. If you can make a two-dimensional array and an array of objects, then why not join these ideas to make a two-dimensional array of objects. Technically, this ends up being an array of arrays of objects. How about that! First you define your two-dimensional array of Room objects. (The declaration of the Room class comes right from Listing 11-5.) Room rooms[][] = new Room[5][10]; Next, you do that all-important step of constructing an object for each component in the array. rooms[floor][roomnum] = new Room(); Then you read values into the array components variables, write values, and so on. A complete program is shown in Listing B-2. Listing B-2 A two-dimensional array of objects import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; import static java.lang.system.out; public class ShowRooms { public static void main(string args[]) throws FileNotFoundException { Room rooms[][] = new Room[5][10]; Scanner myscanner = new Scanner(new File("RoomList")); rooms[floor][roomnum] = new Room(); rooms[floor][roomnum].readroom(myscanner); for (int floor = 4; floor >= 0; floor--) { 4

5 out.println("floor " + floor + ":"); out.print(" "); rooms[floor][roomnum].writeroom(); out.println(); By the time you re done, the program that uses objects is actually simpler than the code that doesn t use objects. That s because, in writing the code with an array of objects, you re taking advantage of methods that are already written as part of the Room class, such as readroom and writeroom. A run of the code in Listing B-2 displays information about all 50 of the hotel s rooms. Instead of showing you all that stuff, Figure B-3 shows you the first several lines in the run. (You don t need to know about every room in the Java Hotel anyway.) The input to the code in Listing B-2, the RoomList file, looks just like the stuff in Listing The only difference is that the RoomList file for this section s code has 150 lines in it. OnTheWeb You can snare a 150-line RoomList file along with this document s code listings from the book s Web site.. Figure B-3: Starting a run of the code from Listing B-2. With all the examples building up to Listing B-2, the code in the listing may be fairly uneventful. The only thing you need to notice is that the line rooms[floor][roomnum] = new Room(); is absolutely, indubitably, 100-percent required. When you accidentally leave off this line (not if you leave off this line, but when you leave off this 5

6 line ), you get a runtime error message saying java.lang.nullpointerexception. 6

### Short Circuit Evaluation of Java's Boolean Operators

Ȱ Ȱ Ȱ 诲盲盶相 相 Short Circuit Evaluation of Java's Boolean Operators Here's a table describing four of Java's boolean operators: Meaning Short circuit? && and yes & and no or yes or no The && and operators

### Using Files as Input/Output in Java 5.0 Applications

Using Files as Input/Output in Java 5.0 Applications The goal of this module is to present enough information about files to allow you to write applications in Java that fetch their input from a file instead

### JAVA ARRAY EXAMPLE PDF

JAVA ARRAY EXAMPLE PDF Created By: Umar Farooque Khan 1 Java array example for interview pdf Program No: 01 Print Java Array Example using for loop package ptutorial; public class PrintArray { public static

### 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

### AP Computer Science File Input with Scanner

AP Computer Science File Input with Scanner Subset of the Supplement Lesson slides from: Building Java Programs, Chapter 6 by Stuart Reges and Marty Stepp (http://www.buildingjavaprograms.com/ ) Input/output

### THE JAVA API. Some of the Java API Packages Package Theme Some Classes Within It. Classes that provide helpful utilities

THE JAVA API The Java API which stands for Application Programming Interface is a repository of prewritten classes provided by the creators of Java to enhance its usefulness. There are classes for creating

### This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output: 1 2 3 4 5 6 7 8 9 10

Java Loops & Methods The while loop Syntax: while ( condition is true ) { do these statements Just as it says, the statements execute while the condition is true. Once the condition becomes false, execution

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

Benjamin Michael Java Homework 3 10/31/2012 1) Sales.java Code // Sales.java // Program calculates sales, based on an input of product // number and quantity sold import java.util.scanner; public class

### 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)

### 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

### 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

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

AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

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

File class in Java File Input and Output (Savitch, Chapter 10) TOPICS File Input Exception Handling File Output Programmers refer to input/output as "I/O". The File class represents files as objects. The

### Basics of Java Programming Input and the Scanner class

Basics of Java Programming Input and the Scanner class CSC 1051 Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/

### D06 PROGRAMMING with JAVA

Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch7 Iteration PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for accompanying

### Two-Dimensional Arrays

Chapter 11 Two-Dimensional Arrays This chapter introduces Java arrays with two subscripts for managing data logically stored in a table-like format in rows and columns. This structure proves useful for

### Arrays in Java. Working with Arrays

Arrays in Java So far we have talked about variables as a storage location for a single value of a particular data type. We can also define a variable in such a way that it can store multiple values. Such

### Scanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard

INPUT & OUTPUT I/O Example Using keyboard input for characters import java.util.scanner; class Echo{ public static void main (String[] args) { Scanner sc = new Scanner(System.in); // scanner for the keyboard

### IRA EXAMPLES. This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account).

IRA EXAMPLES This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account). Definite Counting Loop Example IRA After x Years This first example illustrates

### 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

### 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

### COUNTING LOOPS AND ACCUMULATORS

COUNTING LOOPS AND ACCUMULATORS Two very important looping idioms are counting loops and accumulators. A counting loop uses a variable, called the loop control variable, to keep count of how many cycles

### Course Intro Instructor Intro Java Intro, Continued

Course Intro Instructor Intro Java Intro, Continued The syllabus Java etc. To submit your homework, do Team > Share Your repository name is csse220-200830-username Use your old SVN password. Note to assistants:

### 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

### Lecture J - Exceptions

Lecture J - Exceptions Slide 1 of 107. Exceptions in Java Java uses the notion of exception for 3 related (but different) purposes: Errors: an internal Java implementation error was discovered E.g: out

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

Chapter 2 Console Input and Output System.out.println for console output System.out is an object that is part of the Java language println is a method invoked dby the System.out object that can be used

### 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

### Continuous Integration Part 2

1 Continuous Integration Part 2 This blog post is a follow up to my blog post Continuous Integration (CI), in which I described how to execute test cases in Code Tester (CT) in a CI environment. What I

### Iteration CHAPTER 6. Topic Summary

CHAPTER 6 Iteration TOPIC OUTLINE 6.1 while Loops 6.2 for Loops 6.3 Nested Loops 6.4 Off-by-1 Errors 6.5 Random Numbers and Simulations 6.6 Loop Invariants (AB only) Topic Summary 6.1 while Loops Many

### 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

### 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

### 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

### 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

CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install

### 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

### LOOPS CHAPTER CHAPTER GOALS

jfe_ch04_7.fm Page 139 Friday, May 8, 2009 2:45 PM LOOPS CHAPTER 4 CHAPTER GOALS To learn about while, for, and do loops To become familiar with common loop algorithms To understand nested loops To implement

### 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

### 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

### 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

### 13 File Output and Input

SCIENTIFIC PROGRAMMING -1 13 File Output and Input 13.1 Introduction To make programs really useful we have to be able to input and output data in large machinereadable amounts, in particular we have to

### WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.

WA2099 Introduction to Java using RAD 8.0 Student Labs Web Age Solutions Inc. 1 Table of Contents Lab 1 - The HelloWorld Class...3 Lab 2 - Refining The HelloWorld Class...20 Lab 3 - The Arithmetic Class...25

### This explanations are for absolute beginners. Skilled programmers should (and probably will) use more effective approach.

JAVA EXAMPLES REMARK It turned out that all Workstation in the classroom are NOT set equally. This is why I wil demonstrate all examples using an on-line web tool http://www.browxy.com and/or http://www.compileonline.com.

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

Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******

### 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

### D06 PROGRAMMING with JAVA

Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch16 Files and Streams PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for

### 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

### Building Java Programs

Building Java Programs Chapter 5 Lecture 5-2: Random Numbers reading: 5.1-5.2 self-check: #8-17 exercises: #3-6, 10, 12 videos: Ch. 5 #1-2 1 The Random class A Random object generates pseudo-random* numbers.

### 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

### Array methods that do the following: f) Move all even elements to the front, otherwise preserving order

P6.1 public class ArrayPrinter public static void main(string[] args) int[] data = new int[10]; for (int i = 0; i < 10; i++) data[i] = (int) (Math.random() * 100 + 1); // Print out even indices for (int

### Loops and ArrayLists

Chapter 6 Loops and ArrayLists What is in this Chapter? When programming, it is often necessary to repeat a selected portion of code a specific number of times, or until some condition occurs. We will

### 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

### Chapter 3. Input and output. 3.1 The System class

Chapter 3 Input and output The programs we ve looked at so far just display messages, which doesn t involve a lot of real computation. This chapter will show you how to read input from the keyboard, use

### 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

### 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

### Arrays. Introduction. Chapter 7

CH07 p375-436 1/30/07 1:02 PM Page 375 Chapter 7 Arrays Introduction The sequential nature of files severely limits the number of interesting things you can easily do with them.the algorithms we have examined

### 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

### 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

### Sorting, Searching Arrays: Outline

Arrays Chapter 7 Sorting, Searching Arrays: Outline Selection Sort Other Sorting Algorithms Searching an Array Selection Sort Consider arranging all elements of an array so they are ascending order Algorithm

### In this Chapter you ll learn:

Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis

### java.util.scanner Here are some of the many features of Scanner objects. Some Features of java.util.scanner

java.util.scanner java.util.scanner is a class in the Java API used to create a Scanner object, an extremely versatile object that you can use to input alphanumeric characters from several input sources

### (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

### IMDB Data Set Topics: Parsing Input using Scanner class. Atul Prakash

IMDB Data Set Topics: Parsing Input using Scanner class Atul Prakash IMDB Data Set Consists of several files: movies.list: contains actors.list: contains aka-titles.list:

### Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

### Two-Dimensional Arrays. 15-110 Summer 2010 Margaret Reid-Miller

Two-Dimensional Arrays 15-110 Margaret Reid-Miller Two-Dimensional Arrays Arrays that we have consider up to now are onedimensional arrays, a single line of elements. Often data come naturally in the form

### Comp 248 Introduction to Programming

Comp 248 Introduction to Programming Chapter 2 - Console Input & Output Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has been

### JAVA PRIMITIVE DATA TYPE

JAVA PRIMITIVE DATA TYPE Description Not everything in Java is an object. There is a special group of data types (also known as primitive types) that will be used quite often in programming. For performance

### Introduction to Java. CS 3: Computer Programming in Java

Introduction to Java CS 3: Computer Programming in Java Objectives Begin with primitive data types Create a main class with helper methods Learn how to call built-in class methods and instance methods

2012 coreservlets.com and Dima May Advanced Java Client API Advanced Topics Originals of slides and source code for examples: http://www.coreservlets.com/hadoop-tutorial/ Also see the customized Hadoop

### CS 111 Classes I 1. Software Organization View to this point:

CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects

### A Java array is kind of like a credit card holder Sleeves to put credit cards in

Intro Arrays Page 1 Intro Arrays Thursday, February 16, 2012 11:59 AM A Java array is kind of like a credit card holder Sleeves to put credit cards in Outer case of holder Intro Arrays Page 2 Numbered

### qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui

### Each value (1 through 9) must appear exactly once in each row. Each value (1 through 9) must appear exactly once in each column.

INTRODUCTION TO COMPUTER SCIENCE I PROJECT 6 Sudoku! 1 The game of Sudoku Sudoku is a popular game giving crossword puzzles a run for their money in newspapers. 1 It s a game well suited for computers

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

Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

### 5.2 Q2 The control variable of a counter-controlled loop should be declared as: a.int. b.float. c.double. d.any of the above. ANS: a. int.

Java How to Program, 5/e Test Item File 1 of 5 Chapter 5 Section 5.2 5.2 Q1 Counter-controlled repetition requires a.a control variable and initial value. b.a control variable increment (or decrement).

### 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

### How to create/avoid memory leak in Java and.net? Venkat Subramaniam venkats@durasoftcorp.com http://www.durasoftcorp.com

How to create/avoid memory leak in Java and.net? Venkat Subramaniam venkats@durasoftcorp.com http://www.durasoftcorp.com Abstract Java and.net provide run time environment for managed code, and Automatic

### Week 1: Review of Java Programming Basics

Week 1: Review of Java Programming Basics Sources: Chapter 2 in Supplementary Book (Murach s Java Programming) Appendix A in Textbook (Carrano) Slide 1 Outline Objectives A simple Java Program Data-types

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

Scanner The Scanner class is intended to be used for input. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit. For example, suppose the input

### As activity directory at Lake LazyDays Resort, it is your job to suggest appropriate activities to guests based on the weather:

Chapter 5: Conditionals and Loops Lab Exercises Activities at Lake LazyDays As activity directory at Lake LazyDays Resort, it is your job to suggest appropriate activities to guests based on the weather:

### Event-Driven Programming

Event-Driven Programming Lecture 4 Jenny Walter Fall 2008 Simple Graphics Program import acm.graphics.*; import java.awt.*; import acm.program.*; public class Circle extends GraphicsProgram { public void

### 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

### AP Computer Science Static Methods, Strings, User Input

AP Computer Science Static Methods, Strings, User Input Static Methods The Math class contains a special type of methods, called static methods. A static method DOES NOT operate on an object. This is because

### Building Java Programs

Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: 3.3-3.4 self-check: #16-19 exercises: #11 videos: Ch. 3 #4 Interactive programs We have written programs that print

### Java iteration statements

Java iteration statements Iteration statements are statements which appear in the source code only once, but it execute many times. Such kind of statements are called loops. Almost all the programming

### Line-based file processing

Line-based file processing reading: 6.3 self-check: #7-11 exercises: #1-4, 8-11 Hours question Given a file hours.txt with the following contents: 123 Kim 12.5 8.1 7.6 3.2 456 Brad 4.0 11.6 6.5 2.7 12

### Programming Fundamentals I CS 110, Central Washington University. November 2015

Programming Fundamentals I CS 110, Central Washington University November 2015 Next homework, #4, was due tonight! Lab 6 is due on the 4 th of November Final project description + pseudocode are due 4th

### Threads 1. When writing games you need to do more than one thing at once.

Threads 1 Threads Slide 1 When writing games you need to do more than one thing at once. Threads offer a way of automatically allowing more than one thing to happen at the same time. Java has threads as

### 6.1. Example: A Tip Calculator 6-1

Chapter 6. Transition to Java Not all programming languages are created equal. Each is designed by its creator to achieve a particular purpose, which can range from highly focused languages designed for

### Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

### Data Structures Lecture 1

Fall 2015 Fang Yu Software Security Lab. Dept. Management Information Systems, National Chengchi University Data Structures Lecture 1 A brief review of Java programming Popularity of Programming Languages

### Building a Multi-Threaded Web Server

Building a Multi-Threaded Web Server In this lab we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous

### Chapter 7 Multidimensional Arrays

Chapter 7 Multidimensional Arrays 7.1 Introduction Thus far, you have used one-dimensional arrays to model linear collections of elements. You can use a two-dimensional array to represent a matrix or a

### 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

### 1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 2/6/11 12:33 PM!

1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 2/6/11 12:33 PM! A Foundation for Programming any program you might want

### Q2: Which of the following are valid Java identifiers? If not explain why

Java Programming 1 (Revision) Name: Section#: ID: Q1: True/false 1. A Java identifier can start with a digit. (F) cannot 2. Hello, HELLO, and hello are considered as different identifiers. (T) 3. The name

### CPLEX Tutorial Handout

CPLEX Tutorial Handout What Is ILOG CPLEX? ILOG CPLEX is a tool for solving linear optimization problems, commonly referred to as Linear Programming (LP) problems, of the form: Maximize (or Minimize) c

### Real SQL Programming 1

Real 1 We have seen only how SQL is used at the generic query interface an environment where we sit at a terminal and ask queries of a database. Reality is almost always different: conventional programs

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

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything