Gale Shapley Java Source Code Codes and Scripts Downloads Free. Normalizes Java source code to a clean structured format, customizable through the Sourclet API.
Start display at page:
Download 'A JAVA Program for the Gale-Shapley Algorithm. Dr. Lisa J. Evered. And. William May. Department of Mathematics Iona College'
- Here is the source code of the Java Program to Implement Gale Shapley Algorithm. The Java program is successfully compiled and run on a Windows system.
- I need to implement makeMatches method in stable marriage. Stable Marriage algorithm java code. The program makes couples depend on their first choices but.
- In Gale-Shapley algorithm. The Gale-Shapley Algorithm is an important part of Java. Pseudo code of the Algorithm.
- Code: NRMP Example. Gale Shapley Algorithm for Stable Matching - Duration: 9:59.
- This algorithm, developed by David Gale and Lloyd S. Basic programming in python (functions, loops, recursion), common sense and curiosity.
- Randolf Wood
- 2 years ago
- Views:
Transcription
1 A JAVA Program for the Gale-Shapley Algorithm Dr. Lisa J. Evered And William May Department of Mathematics Iona College 1
2 A JAVA Program for the Gale-Shapley Algorithm The Gale-Shapley algorithm was developed to pair men and women who had expressed their individual preferences about one another. Their pairings should result in stable marriages. A marriage is considered stable if no spouse is motivated to select another. Perhaps the problem is not realistic but it has attracted considerable mathematical interest. If there are 100 men and 100 women, each of who have ranked those of the opposite gender from 1 to 100, the Gale-Shapley algorithm will indeed match 100 couples in stable marriages. With so many men and women the algorithm is lengthy and tedious. The following example pairs four men with four women. The first number of each entry gives the ranking of the women by the men. The second number in the entry is the ranking of the men by the women. Michelle Teresa Kim Ashley Brent 1,3 2,2 3,1 4,3 Mike 1,4 2,3 3,2 4,4 Jason 3,1 1,4 2,3 4,2 Dennis 2,2 3,1 1,4 4,1 The Gale-Shapley procedure uses these rankings to determine stable pairings. First, assign each man to the woman he most prefers. If two or more men ask the same woman, she must choose whom she prefers. The other men then ask the next woman on their lists. After the first application of the Gale-Shapley procedure, the pairs look like this: 2
3 Brent, Michelle Mike, Michelle Jason, Teresa Dennis, Kim Since both Brent and Mike prefer Michelle, Michelle must choose between them. Notice that Michelle s first two choices, Jason and Dennis, are temporarily taken and she must chose her third choice, Brent. Mike s second choice is Teresa. After Round 2, the pairs look like this: Brent, Michelle Mike, Teresa Jason, Teresa Dennis, Kim Now both Mike and Jason prefer Teresa, so Teresa must choose between them. Teresa s first and second choices are temporarily taken so she chooses here third choice, Mike. Jason picks his second choice, Kim. After Round 3, the pairs look like this: Brent, Michelle Mike, Teresa Jason, Kim Dennis, Kim This process should be continued until stable pairings are obtained. In all, ten Gale-Shapley iterations are needed. Can you show that the final pairings are as follows? Brent, Kim Mike, Ashley Jason, Michelle Dennis, Teresa The algorithms complexity is polynomial -- for n individuals the complexity is n 2. Clearly for n larger than, say ten, the algorithm becomes impracticable for most who may wish to use it. A computer program that implements the Gale-Shapley algorithm electronically is needed (see appendix 1). Design of this algorithm and its application in simple cases is an interesting project for computer science students even at the high school level. 3
4 following: The flow chart for the Gale-Shapley algorithm will look something like the Step 1 Step 2 Step 3 Start Assign to each boy the available girl highest on the boy s preference list. For any girl assigned to two boys, select the boy highest on the girl s preference list. For each unmatched boy, select an unassigned girl highest on the boy s preference list. Are the assignments one-to-one? No? Return to step 2. Yes? Stop The computer language that my college student preferred to use is JAVA. While other programs are more sophisticated programmatically, the program produced here is faithful to the algorithm and when applied to the 4x4 marriage problem above, arrives at stable pairings quickly and correctly. It should be noted that stable pairings are not necessarily unique; however the algorithm given produces a single pairing for each preference matrix provided. The stable marriage problem has spawned considerable variations. It would be unreasonable for 100 women to rank 100 available men in serial order. A more realistic ordering might be to rank the three highest preferences, 1, 2, and 3 and the three lowest preferences, 98, 99, and 100 with no ranking attempted among the ninety-four remaining males. Could the Gale-Shapley algorithm be altered to accommodate rankings of this kind? 4
5 A more interesting variation asks if it is possible to enhance an individual s spousal assignment by submitting specious preferences. This possibility is the subject of contemporary research in game theory. Results indicate that perhaps honesty may not be the best policy when confronted by a computer algorithm that makes choices on our behalf. REFERENCES Gale, D., and L.S. Shapley College Admissions and the Stability of Marriage. American Mathematical Monthly 69: Roth, Alvin The Economist As Engineer: Game Theory, Experimentation, and Computation As Tools For Design Economists. Econometrica 70, no.4: Teo, C., J. Sethuraman, and W. Tan. Gale-Shapley Stable Marriage Problem Revisited: Strategic Issues and Applications. Management Science 47, no. 9 (2001):
6 // StableMarriage.java // William May // March 14, 2011 import java.util.*; public class StableMarriage { public static void main(string[] args) { System.out.print('How many pairs would you like to match up? '); Scanner input = new Scanner (System.in); int NUMBER_OF_COUPLES = input.nextint(); System.out.println(); LinkedList eligiblemen = createeligiblemen(number_of_couples); System.out.println(); LinkedList eligiblewomen = createeligiblewomen(number_of_couples); System.out.println(); createpreferences(eligiblemen, eligiblewomen); createpreferences(eligiblewomen, eligiblemen); SocialRegister sr = new SocialRegister(eligibleMen,eligibleWomen); System.out.println(sr); while (sr.eligiblemenexist()) { sr.getfirsteligible().makeproposal(); System.out.println(sr); static LinkedList createeligiblemen(int number) { System.out.println('What are the names of the men? (Press Enter to submit a name)'); LinkedList men = new LinkedList(); Scanner input = new Scanner (System.in); for (int i = 1; i <= number; i++) men.add(new Man(input.next())); return men; static LinkedList createeligiblewomen(int number) { System.out.println('What are the names of the women? (Press Enter to submit a name)'); LinkedList women = new LinkedList(); Scanner input = new Scanner (System.in); for (int i = 1; i <= number; i++) women.add(new Woman(input.next())); return women; static void createpreferences(linkedlist a, LinkedList b) { Iterator it = a.listiterator(); 6
7 while (it.hasnext()) { Person p = (Person) it.next(); Rankings r = p.getrankings(); r.addall(b); System.out.println('What are the preferences of ' + p.name + '? (Input numeric position of persons)'); Scanner input = new Scanner (System.in); int n = r.size(); for (int i = 0; i < n; i++) { int loc = input.nextint() - 1; r.add(r.get(loc)); // put it at the back for (int i = 0; i < n; i++) r.removefirst(); class SocialRegister { public static SocialRegister defaultregister; // singleton pattern LinkedList eligiblemen, women; HashMap engagements; // maps Women to Men SocialRegister(LinkedList eligiblemen, LinkedList eligiblewomen) { defaultregister = this; this.eligiblemen = eligiblemen; women = eligiblewomen; engagements = new HashMap(); boolean eligiblemenexist() { return!eligiblemen.isempty(); Man getfirsteligible() { return (Man) eligiblemen.get(0); void createengagement(woman w, Man m) { if (engagements.containskey(w)) eligiblemen.add(engagements.get(w)); engagements.put(w,m); eligiblemen.remove(m); public String tostring() { String result = '; if (eligiblemenexist()) { result += 'n ELIGIBLE MEN: n' + showlist(eligiblemen); result += ' WOMEN: n' + showlist(women); result += ' ENGAGEMENTS: n'; else { result += ' MARRIAGES: n'; result += showengagements(); return result; 7
8 'n'; String showlist(linkedlist eligible) { String result = '; Iterator it = eligible.listiterator(); while (it.hasnext()) { Person p = (Person) it.next(); result += ' ' + p + ':' + p.getrankings() + return result; String showengagements() { String result = '; Set couples = engagements.entryset(); // get the set of couples Iterator it = couples.iterator(); while (it.hasnext()) { Map.Entry couple = (Map.Entry) it.next(); result += ' (' + couple.getkey() + ',' + couple.getvalue() + ')n'; return result; class Rankings extends LinkedList { public void trim(object x) { // removes x and all elements after it Iterator it = listiterator(); boolean found = false; while (!found) if (it.next() x) { found = true; it.remove(); while (it.hasnext()) { it.next(); it.remove(); public String tostring() { String result = '; Iterator it = listiterator(); while (it.hasnext()) result += ' ' + it.next(); return result; class Person { String name; Rankings preferences; 8
9 Person(String name) { this.name = name; preferences = new Rankings(); Rankings getrankings() { return preferences; public String tostring() { return name; class Man extends Person { Man(String name) { super(name); void makeproposal() { ((Woman) preferences.removefirst()).considerproposal(this); class Woman extends Person { Woman(String name) { super(name); void considerproposal(man m) { if (preferences.contains(m)) { SocialRegister.defaultRegister.createEngagement(this,m); preferences.trim(m); 9
Java Class Library. Java the platform contains around 4,000 classes/interfaces
Java Class Library Java the platform contains around 4,000 classes/interfaces Data Structures Networking, Files Graphical User Interfaces Security and Encryption Image Processing Multimedia authoring/playback
More information THE ROOMMATES PROBLEM DISCUSSED
THE ROOMMATES PROBLEM DISCUSSED NATHAN SCHULZ Abstract. The stable roommates problem as originally posed by Gale and Shapley [1] in 1962 involves a single set of even cardinality 2n, each member of which
More information 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
More information Stable matching: Theory, evidence, and practical design
THE PRIZE IN ECONOMIC SCIENCES 2012 INFORMATION FOR THE PUBLIC Stable matching: Theory, evidence, and practical design This year s Prize to Lloyd Shapley and Alvin Roth extends from abstract theory developed
More information 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
More information Introduction to Programming
Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems [email protected] Spring 2015 Week 2b: Review of Week 1, Variables 16 January 2015 Birkbeck
More information 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 Java How to Program, 9/e
Java How to Program, 9/e Education, Inc. All Rights Reserved. 1 Any computing problem can be solved by executing a series of actions in a specific order. An algorithm is a procedure for solving a problem
More information 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 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 What s Wrong with This?
More Sophisticated Behaviour 2 Using library classes to implement more advanced functionality. Also class (static( static) ) fields. What s Wrong with This? class Notebook private ArrayList notes;
More information 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 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 Collections in Java. Arrays. Iterators. Collections (also called containers) Has special language support. Iterator (i) Collection (i) Set (i),
Arrays Has special language support Iterators Collections in Java Iterator (i) Collections (also called containers) Collection (i) Set (i), HashSet (c), TreeSet (c) List (i), ArrayList (c), LinkedList
More information 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 Dimitris Chatzidimitriou. Corelab NTUA. June 28, 2013
AN EFFICIENT ALGORITHM FOR THE OPTIMAL STABLE MARRIAGE PROBLEM Dimitris Chatzidimitriou Corelab NTUA June 28, 2013 OUTLINE 1 BASIC CONCEPTS 2 DEFINITIONS 3 ROTATIONS 4 THE ALGORITHM DIMITRIS CHATZIDIMITRIOU
More information Java Program Download
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 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 Data Structures and Algorithms
Data Structures and Algorithms CS245-2016S-05 Abstract Data Types and Lists David Galles Department of Computer Science University of San Francisco 05-0: Abstract Data Types Recall that an Abstract Data
More information Two-Sided Matching Theory
Two-Sided Matching Theory M. Utku Ünver Boston College Introduction to the Theory of Two-Sided Matching To see which results are robust, we will look at some increasingly general models. Even before we
More information The Java Collections Framework
The Java Collections Framework Definition Set of interfaces, abstract and concrete classes that define common abstract data types in Java e.g. list, stack, queue, set, map Part of the java.util package
More information 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 Techniques
Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary
More information CASCADING IF-ELSE. Cascading if-else Semantics. What the computer executes: What is the truth value 1? 3. Execute path 1 What is the truth value 2?
CASCADING IF-ELSE A cascading if- is a composite of if- statements where the false path of the outer statement is a nested if- statement. Types of harpsichords. The nesting can continue to several levels. Cascading if- Syntax
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 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 Object-Oriented Programming in Java
Object-Oriented Programming in Java Quiz 1 Jan 10, 2001 Problem 1: Who wants to be a Java developer? (with apologies to Regis) Fill in your answer in the space provided. Question 1: Which is these word-pairs
More information JAVA COLLECTIONS FRAMEWORK
http://www.tutorialspoint.com/java/java_collections.htm JAVA COLLECTIONS FRAMEWORK Copyright tutorialspoint.com Prior to Java 2, Java provided ad hoc classes such as Dictionary, Vector, Stack, and Properties
More information More sophisticated behaviour
Objects First With Java A Practical Introduction Using BlueJ More sophisticated behaviour Using library classes to implement some more advanced functionality 2.0 Main concepts to be covered Using library
More information Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
More information Basic Programming and PC Skills: Basic Programming and PC Skills:
Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of
More information 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 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
More information Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
More information 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 1.1 A First Problem: Stable Matching
Matching Residents to Hospitals 1.1 First Problem: Stable Matching Goal. Given a set of preferences among hospitals and medical school students, design a self-reinforcing admissions process. Unstable pair:
More information API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.
Sequences and Urns 2.7 Lists and Iterators Sequence. Ordered collection of items. Key operations. Insert an item, iterate over the items. Design challenge. Support iteration by client, without revealing
More information Object Oriented Software Design
Object Oriented Software Design Inner classes, RTTI, Tree implementation Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 29, 2010 G. Lipari (Scuola Superiore Sant
More information 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
More information 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/
More information 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 CSE 142 Sample Final Exam #1 (based on Spring 2005's final; thanks to Stuart Reges)
1. Array Mystery Consider the following method: CSE 142 Sample Final Exam #1 (based on Spring 2005's final; thanks to Stuart Reges) public static void arraymystery(int[] a) { for (int i = 1; i < a.length;
More information Data Structures and Algorithms Lists
Data Structures and Algorithms Lists Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/19 5-0: Abstract Data Types An
More information 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
More information 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 Data Structures in the Java API
Data Structures in the Java API Vector From the java.util package. Vectors can resize themselves dynamically. Inserting elements into a Vector whose current size is less than its capacity is a relatively
More information 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 Implied Main Ideas main idea supporting details implied
Implied Main Ideas Anything you read has two basic parts: a main idea and the supporting details that explain and develop that idea. The main idea is usually clearly stated in one sentence of a selection.
More information Java 進 階 程 式 設 計 03/14~03/21
Java 進 階 程 式 設 計 03/14~03/21 Name: 邱 逸 夫 NO:942864 2.30 Write an application that inputs one number consisting of five digits from the user, separates the number into its individual digits and prints the
More information 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
More information Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
More information We study strategic issues in the Gale-Shapley stable marriage model. In the first part
Gale-Shapley Stable Marriage Problem Revisited: Strategic Issues and Applications Chung-Piaw Teo Jay Sethuraman Wee-Peng Tan Department of Decision Sciences, Faculty of Business Administration, National
More information SCIENCE SUBJECT COMBINATIONS
TRENDS IN MATHEMATICS AND SCIENCE SUBJECT COMBINATIONS IN THE NSW HSC 2001-2014 BY GENDER As an analysis of mathematics/science subject combination choices made by NSW HSC students 2001-2014, this study
More information Programming Languages CIS 443
Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception
More information The Student-Project Allocation Problem
The Student-Project Allocation Problem David J. Abraham, Robert W. Irving, and David F. Manlove Department of Computing Science, University of Glasgow, Glasgow G12 8QQ, UK Email: {dabraham,rwi,davidm}@dcs.gla.ac.uk.
More information 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 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 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 CS114: Introduction to Java
CS114: Introduction to Java Fall 2015, Mon/Wed, 5:30 PM - 6:45 PM Instructor: Pejman Ghorbanzade to Assignment 4 Release Date: Nov 04, 2015 at 5:30 PM Due Date: Nov 18, 2015 at 5:30 PM Question 1 An n
More information Fundamentals of Programming. Laboratory 5 Methods. General-purpose and user - defined methods
Fundamentals of Programming Laboratory 5 Methods. General-purpose and user - defined methods What is a method? Block of code that receives its own identifier - i.e. can be executed using its name Different
More information Design Patterns. Advanced Software Paradigms (A. Bellaachia) 1
Design Patterns 1. Objectives.. 2 2. Definitions.. 3 2.1. What is a Pattern?.. 3 2.2. Categories of Patterns.. 4 3. Pattern Characteristics [Buschmann]:.. 5 4. Essential Elements of a Design Pattern
More information 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 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 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 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
More information Main concepts to be covered. Designing classes. Change or die. Software changes. World of Zuul. Adventure game
Main concepts to be covered Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable Responsibility-driven design It's not my area of expertise Coupling
More information 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
More information 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
More information Remarriage in the United States
Remarriage in the United States Poster presented at the annual meeting of the American Sociological Association, Montreal, August 10-14, 2006 Rose M. Kreider U.S. Census Bureau [email protected]
More information 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
More information CS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper
More information 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).
More information 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
More information The first step in solving a problem recursively is to formulate a recursive definition of the problem.
Chapter 8 Recursion The subject of this chapter is recursion, an implicit application of the stack ADT. A recursive method is a method that carries out its task by making a call(s) to itself. Each recursive
More information Social Security: Common Questions Concerning Retirement Benefits
EDUCATION: SOCIAL SECURITY Social Security: Common Questions Concerning Retirement Benefits You have worked hard your entire life and finally find yourself on the verge of retirement, steps away from filling
More information Object-Oriented Design Concepts via Playing Cards Owen Astrachan Duke University
Object-Oriented Design Concepts via Playing Cards Owen Astrachan Duke University Most students have played card games: blackjack, war, hearts, solitaire, bridge. The list of games isn't infinite, but it's
More information Learning to Play 33 Games: Neural Networks as Bounded-Rational Players Technical Appendix
Learning to Play 33 Games: Neural Networks as Bounded-Rational Players Technical Appendix Daniel Sgroi 1 Daniel J. Zizzo 2 Department of Economics School of Economics, University of Warwick University
More information The Status of Women in the Middle East and North Africa (SWMENA) Project
The Status of Women in the Middle East and North Africa (SWMENA) Project Focus on Morocco Social Attitudes Toward Women Topic Brief A project by the International Foundation for Electoral Systems (IFES)
More information CSE 142, Spring 2009 Midterm Exam Answer Key
CSE 142, Spring 2009 Midterm Exam Answer Key 1 of 9 1. Expressions For each expression in the left-hand column, indicate its value in the right-hand column. Be sure to list a constant of appropriate type
More information Implementation Committee for Gender Based Salary Adjustments (as identified in the Pay Equity Report, 2005)
Implementation Committee for Gender Based Salary Adjustments (as identified in the Pay Equity Report, 2005) Final Report March 2006 Implementation Committee for Gender Based Salary Adjustments (as identified
More information Matching with Waiting Times: The German Entry-Level Labor Market for Lawyers
Matching with Waiting Times: The German Entry-Level Labor Market for Lawyers Philipp D. Dimakopoulos and C.-Philipp Heller Humboldt University Berlin 8th Matching in Practice Workshop, Lisbon, 2014 Dimakopoulos
More information CS 1302 Ch 19, Binary I/O
CS 1302 Ch 19, Binary I/O Sections Pages Review Questions Programming Exercises 19.1-19.4.1, 19.6-19.6 710-715, 724-729 Liang s Site any Sections 19.1 Introduction 1. An important part of programming is
More information Implementation Committee for Gender Based Salary Adjustments (as identified in the Pay Equity Report, 2005)
Implementation Committee for Gender Based Salary Adjustments (as identified in the Pay Equity Report, 2005) Final Report March 2006 Implementation Committee for Gender Based Salary Adjustments (as identified
More information
CMSC 132: Object-Oriented Programming II. Design Patterns I. Department of Computer Science University of Maryland, College Park
CMSC 132: Object-Oriented Programming II Design Patterns I Department of Computer Science University of Maryland, College Park Design Patterns Descriptions of reusable solutions to common software design
More information The Status of Women in the Middle East and North Africa (SWMENA) Project
The Status of Women in the Middle East and North Africa (SWMENA) Project Focus on Lebanon Social Attitudes Toward Women Topic Brief A project by the International Foundation for Electoral Systems (IFES)
More information The Status of Women in the Middle East and North Africa (SWMENA) Project
The Status of Women in the Middle East and North Africa (SWMENA) Project Focus on Lebanon Social Attitudes Toward Women Topic Brief A project by the International Foundation for Electoral Systems (IFES)
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
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 Software Engineering II. Java 2 Collections. Bartosz Walter <[email protected]>
Software Engineering II Java 2 Collections Bartosz Walter Agenda 1. Basic interfaces: Collection, Set, List, Map 2. Iterators 3. Utility classes for Collections and Arrays
Gale Shapley Algorithm For Hr
More informationReading 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 1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders
1.00 Lecture 1 Course Overview Introduction to Java Reading for next time: Big Java: 1.1-1.7 Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders
More information 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
More information 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:
Lecture 7 Picking Balls From an Urn The problem: An urn has n (n = 10) balls numbered from 0 to 9 A ball is selected at random, its' is number noted, it is set aside, and another ball is selected from
More information 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
Gale Shapley Matlab
More informationqwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui
More information Author Gender Identification of English Novels
Author Gender Identification of English Novels Joseph Baena and Catherine Chen December 13, 2013 1 Introduction Machine learning algorithms have long been used in studies of authorship, particularly in
More information The Role of Priorities in Assigning Indivisible Objects: A Characterization of Top Trading Cycles
The Role of Priorities in Assigning Indivisible Objects: A Characterization of Top Trading Cycles Atila Abdulkadiroglu and Yeon-oo Che Duke University and Columbia University This version: November 2010
More information 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
More information Matching Markets: Theory and Practice
Matching Markets: Theory and Practice Atila Abdulkadiroğlu Duke University Tayfun Sönmez Boston College 1 Introduction It has been almost half a century since David Gale and Lloyd Shapley published their
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 NOTE: SUN ONE Studio is almost identical with NetBeans. NetBeans is open source and can be downloaded from www.netbeans.org. I
More information Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
More information