# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

20 Pages

### c5

Course: ECE 122, Fall 2009
School: UMass (Amherst)
Rating:

Word Count: 706

#### Document Preview

10, ECE122 Feb 2005 Unary Operator An operator that takes only a single operand Plus: + Minus: Cast: (type). E.g. (double) Compound Assignment Operator Operator += -= *= /= %= Example x += y x -= y x *= y x /= y x %= y Meaning x=x+y x=x-y x=x*y x=x/y x=x%y Increment &amp; Decrement Operator Prefix increment ++ e.g. ++i Increase i by 1, then use the new value of i to evaluate the expression that i...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Massachusetts >> UMass (Amherst) >> ECE 122

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
10, ECE122 Feb 2005 Unary Operator An operator that takes only a single operand Plus: + Minus: Cast: (type). E.g. (double) Compound Assignment Operator Operator += -= *= /= %= Example x += y x -= y x *= y x /= y x %= y Meaning x=x+y x=x-y x=x*y x=x/y x=x%y Increment & Decrement Operator Prefix increment ++ e.g. ++i Increase i by 1, then use the new value of i to evaluate the expression that i resides Postfix increment ++ e.g. i++ Use the current value of i to evaluate the expression that i resides, then increase i by 1 Prefix decrement -e.g. --i Decrease i by 1, then use the new value of i to evaluate the expression that i resides Postfix decrement -e.g. I\-Use the current value of i to evaluate the expression that i resides, then decrease i by 1 Operator Precedence Operator ++ -++ -- + * / % + < <= > >= == != ?: = += -= *= /= %= Type Unary postfix Unary prefix multiplicative additive relational equality conditional assignment Pseudo Code Pseudo code is informal language that helps programmer THINK and develop algorithm without worrying about strict Java language. Pseudo code can be written in plain English. Pseudo code doesn't need to execute on a computer Pseudo code and real code Pseudo code If test score is higher than or equal to 60, Print out the message to console, "I passed". If the test score is lower than 60, Print out the message to console, "I failed". Java code if (testScore >= 60) System.out.println("I passed"); else System.out.println("I failed"); switch statement Multiple selection statement. Perform a different action dependent on the value of a variable or expression. The value of the variable or expression can only be any of data type of byte, short, int, or char. Example of switch statement switch (temperature/10) { case 9: System.out.println("The temperature is higher than 90."); break; //Cannot omit this case 8: System.out.println("The temperature is between 80 and 90."); break; default: System.out.println("The temperature is between 70 and 80."); break; } break Statement The "break" statement, when executed in a "switch", "while", "for", "do...while" causes immediate exit from that statement. Execution continues with the first statement after the control statement. Common uses of the break statement are to skip the of remainder a switch. Without a break statements, each time a match occurs in the switch, the statements for that case and subsequent cases execute until a break statement or the end of the switch is encountered. "Falling through" to the statements in subsequent cases. It is a good practice to have "break" statement at the end of each "case", so that accidental falling through will not happen. while loop A repetition statement (loop) allows a block of code between {} to repeat while some condition remains true. Braces can be omitted if the block statement is a single statement. int i = 10; while (i < 100) i = i + 10; Counter-controlled Repetition Use a variable called a counter (or control variable) to control the number of repetition. Definite repetition. The number of repetition is known before the loop begins executing. Example: WhileStatement Nested Control Structure Control statement can be nested with each other to create a more power control structure. int j = 5; while (j > 0) { if (j > 2) System.out.println("i is "+ j + " and is greater than 2"); else System.out.println("i is " + j + " and is less than 2"); j = j - 1; } do...while repetition statement Similar to while repetition statement In while statement, the program will evaluate loop-continuation condition first before executing any statement. In do...while statement, the program will execute the statement at least once before evaluating loop-continuation condition Compare do...while and while do...while int k = -1; do { System.out.println("k="+k); //This statement execute } while (k > 0); While int l = -1; while (l > 0) { System.out.println("l="+l); //This statement will not execute } Demo do...while Essential of Counter-controlled Repetition A control variable (loop counter) The initial value of control variable The increment (or decrement) by which the control variable is modified each time through the loop (each iteration of the loop). The loop-continuation condition that determines whether looping should continue. while/do..while generalization While statement Initialization; while (loopContinuationCondition) { statement; increment; } Do..while statement Initialization; Do { statement; increment; } while (loopContinuationCondition) Reading Assignment "Java 2" p78-83, 92-97, p100-106, p112113
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UMass (Amherst) - ECE - 122
ECE 122Feb. 8, 2005if Statement A condition is an expression that can be either true, or false. if statement allows a program to make a decision based on the value of a condition.Equality Operators = e.g. x=y != e.g. x!=y means x is equal to
UMass (Amherst) - ECE - 122
ECE 122Feb. 1, 2005Introduction to EclipseJava Statements Declaration Assignment Method callsDeclaration A variable is like a container that can hold certain content/ value. Variable declaration consists of type and name Variable name, b
UMass (Amherst) - ECE - 122
ECE122Feb. 17. 2005Introduction to Class and Object Java is an object-oriented language. Javas view of the world is a collection of objects and their interactions. Class is a template, or blueprint to build objects. Objects are instantiated (c
UMass (Amherst) - ECE - 122
ECE 122Feb. 15, 2005for Repetition Statement for (int i=0; i&lt;5; i+) System.out.println(i); Generalizationfor(initialization; loopContinuationCondition; increment) statement; Better use integer as counter Demo for statementCommon Programmin
UMass (Amherst) - ECE - 122
ECE 122March 24Motivation I am tasked to write two classes, one for cat, one for sheep. That is easy. I roll up my sleeve and get it done!Here is my class for catimport java.io.*;/importing java I/O package public class Cat1 { File imageFile;
UMass (Amherst) - ECE - 122
ECE 122We know thisCat cat = new Cat(); Animal animal = new Animal();and this? Animal animal = new Cat(); An object reference of super class type points to an object of sub class type. It is legal and it is called polymorphism.Motivation L
UMass (Amherst) - ECE - 122
ECE 122Feb. 3, 2005Java Data Types Primitive types. boolean, byte, char, short, int, long, float, double Reference Type. Class.boolean 1 bit of data. Can only be of two value, true or false Declaration: boolean b; Assignment: b = true; b =
UMass (Amherst) - ECE - 122
ECE122March 22, 2005ScopeEncapsulation Encapsulation is a feature of object-oriented world. We don't want to put a million lines of code in the main method to solve a large complex problem. It is too complex to comprehend and difficult to dele
UMass (Amherst) - ECE - 122
ECE122March 29, 2005Another Example of Inheritance I want to write classes of medical doctors. One is family practitioner, one surgeon. How many classes do I need? What are they? Can I use inheritance? What should I put in super class? What
UMass (Amherst) - ECE - 122
A1 import java.awt.FlowLayout; import java.awt.event.*; import javax.swing.JButton; import javax.swing.JFrame; public class TwoButtonsInnerClass { JButton button1; JButton button2; public void go() { try{ JFrame frame = new JFrame(); frame.getContent
UMass (Amherst) - ECE - 122
Q1 Write a program that shows a Java Jframe with FlowLayout manager. There are two buttons on the frame initially displayed with text &quot;button&quot;. When user clicks on any button, the button text changed to &quot;clicked&quot; Q2 write a class that inherit from th
UMass (Amherst) - ECE - 122
ECE 122 Spring 2005 Exam #1 Name_ Student ID_ Discussion Session (circle one): (1) Wednesday 10:10am 11am (2) Wednesday 11:15am 12:05pm (3) Wednesday 1:25pm-2:15pm (4) Wednesday 2:30pm-3:20pm Open Notes, open books, no computers. Please note: If yo
UMass (Amherst) - ECE - 122
Answer to Exam 1 Question #1 The output of the code is: 0 1 2 This is a straight forward question. It tests your knowledge of &quot;for statement&quot;. The counter variable is i, i is initialized to be zero, the loop continuation condition is &quot;i&lt;3&quot;, the count
UMass (Amherst) - ECE - 122
Answer to Exam 1 Q1 5 4 3 2 1 Q2 case 3 Q3 should use &quot;continue&quot;, not &quot;break&quot; should use i-, not i+ should have i- before continue Correct code: public void q3() { int i = 6; while (i&gt;0) { if (i=3) { i-; continue; } System.out.println(i); i-; } }
UMass (Amherst) - ECE - 122
ECE 122 Spring Semester Exam2 Answer A1:Car:startEngine BMW7:turn BMW7:cruiseControl BMW7:temperatureControlSince BMW7 doesnt override startEngine() method, so it inherits it from Car class. Since BMW7 override turn() method, so the overridden met
UMass (Amherst) - ECE - 122
ECE 122 Spring Semester Sample Exam2 Answer A1:MyClass:method1 MySubClass:method2 MySubClass:method3Since MySubClass doesnt override method1() method, so it inherits it from MyClass class. Since MySubClass override method2() method, so the overrid
UMass (Amherst) - ECE - 122
ECE 122 Spring 2005 Sample Exam #2 Name_ Student ID_ Discussion Session (circle one): (1) Wednesday 10:10am 11am (2) Wednesday 11:15am 12:05pm (3) Wednesday 1:25pm-2:15pm (4) Wednesday 2:30pm-3:20pm Q1 (25/100) What is the output of the following c
UMass (Amherst) - ECE - 122
private int _year; private int _month; private int _day; public Date(int year, int month, int day) { this._year = year; this._month = month; _day = day; } public static void test() { Date d1 = new Date(2005, 3, 2);
UMass (Amherst) - ECE - 122
public String toString() { return &quot;'Date object [&quot;+ &quot;y=&quot; + _year + &quot;, m=&quot; + _month + &quot;, d=&quot; + _day + &quot;]'&quot;; }
UMass (Amherst) - ECE - 122
public static int daysInYear(int year) { return 365 + (isLeapYear(year) ? 1 : 0); } public static int daysInMonth(int year, int month) { int count; switch (month) { case 9: / Thirty
UMass (Amherst) - ECE - 122
public static boolean isLeapYear(int year) { / A leap year / if year is divisible by 4, but not 100, / OR year is divisible by 400: return (year % 4) = 0 &amp; / year divisible by 4 (year % 100) != 0) | / and not
UMass (Amherst) - ECE - 122
public int epoch() { final int origin = 1970; int total = 0; if (_year &gt;= origin) { for (int y=origin; y &lt; _year; y+) { total += daysInYear(y); } total += dayOfYear(); }
UMass (Amherst) - CS - 187
Self-Balancing Search TreesBased on Chapter 11 of Koffmann and WolfgangChapter Outline The impact of balance on search tree performance Balanced binary search trees: AVL trees Red-Black trees Other balanced search trees: 2-3 trees 2-3-4 tr
UMass (Amherst) - CS - 187
Self-Balancing Search TreesBased on Chapter 11 of Koffmann and WolfgangChapter Outline The impact of balance on search tree performance Balanced binary search trees: AVL trees Red-Black trees Other balanced search trees: 2-3 trees 2-3-4 tr
UMass (Amherst) - CS - 187
Class Hierarchy IIDiscussion EHierarchyA mail order business sells catalog merchandise all over the country. The rules for taxation on the merchandise vary from state to state. Also, the rate of taxation can be different based on the type of mer
Cal Poly Pomona - ENGLISH - 465
465 PORTFOLIO ASSIGNMENTDIRECTIONS:Your portfolio should present a portrait of you as an English major. It will be comprised of five sections. Section 1 will include representative samples of the work you have done during the last 3-4 years, along
Cal Poly Pomona - ECE - 425
Review Chapter 5We started from04/21/09ece425 M. Yin1To this single-cycle design (with simple datapath and control unit)04/21/09ece425 M. Yin2What's different here?04/21/09ece425 M. Yin3The main problem with the single-cycle
UMass (Amherst) - BIEP - 640
1Intermediate Biostatistics Computer Illustration Logistic Regresion Software: Minitab v 14Data: Source: Afifi A., Clark VA and May S. Computer Aided Multivariate Analysis, Fourth Edition. Boca Raton: Chapman and Hall, 2004. These data are a stud
UMass (Amherst) - ACCODEV - 3
UMass (Amherst) - ACCODEV - 3
WebCT: Powerpoint - Macpage 1 of 6UMass Office of Information TechnologiesoitWebCT: Powerpoint Presentations Macintosh1. Apply Existing Office Updates and Patches 2. Linking to a PowerPoint Presentation (PPT or PPS) 3. Viewing an Unconverted
UMass (Amherst) - ACCODEV - 3
UMass (Amherst) - ACCODEV - 3
WebCT: Powerpoint - Windowspage 1 of 6UMass Office of Information TechnologiesoitWebCT: Powerpoint Presentations Windows1. Apply Existing Office Updates and Patches 2. Linking to a PowerPoint Presentation (PPT or PPS) 3. Viewing an Unconvert
UMass (Amherst) - ACCODEV - 3
2000-2002 by Respondus, Inc. All Rights reserved. The Equation Editor and documentation are copyrighted by Design Science, Inc. The Sentry Spelling-Checker Engine is copyrighted by Wintertree Software, Inc. Respondus is a registered trademark of Res
UMass (Amherst) - ACCODEV - 3
Respondus 2.0User Guide for WebCT Personalityrev. January 23, 2003Getting Started Computer Requirements Installation &amp; Setup Activation Password Choose a Course Management System (CMS) Personality On-line Help Start Menu Overview Opening a File C
UMass (Amherst) - BIEP - 540
PubHlth 540 2007 Exam II1PubHlth 540 - Introductory Biostatistics Fall 2007 Examination II(Topics 4 and 5)Please, please you are NOT allowed to submit more than one solution to a question and ask me to choose the correct one.PHP Program On
UMass (Amherst) - SOM - 640
Hello everyone, Here are some tips on understanding the solutions to chapter 6 problems: P1 and P2. These problems are well explained P3. In problem 3, the total annual operating costs are given as (see line 5 of the solution on page 86): Annual Vari
UMass (Amherst) - RESEC - 453
Public Policy in Private MarketsThe Policy ProcessAnnouncementsTentative Presentation Schedule is posted (first case in two weeks) Homework 1 will be posted soon and is due on Feb. 12TodaySteps in the policy process Sources of possible g
UMass (Amherst) - ECON - 313
Answer to Assignment #2 Econ 313 1.Vaccinations produce positive externalities, since one individuals receiving a shot reduces his chances of getting sick as well as the chances of those around him. But that individual does not take into account the
UMass (Amherst) - RESEC - 262
Lecture 13: Transferable Discharge PermitsThis is another incentive-based policy. Components of a simple transferable discharge permit policy: 1. Regulator chooses a level of aggregate emissions that it wants to achieve. 2. Constructs permits to emi
UMass (Amherst) - RESEC - 262
Worksheet: Emissions Taxes and Transferable Discharge PermitsIn the following table are the marginal abatement costs of two firms. We will use this information to illustrate various aspects of emissions taxes and transferable discharge permits. Not
UMass (Amherst) - RESEC - 262
Lecture 3.1: Demand and Benefits To choose a policy to control environmental problems we ultimately want to balance the benefits of a policy against the costs of a policy. Therefore, we must understand the economic concepts of benefits and costs. Ben
UMass (Amherst) - BMAT - 353
UMass (Amherst) - BMAT - 352
Pricing Considerations and ApproachesChapter 11Objectives Understand the internal factors affecting a firm's pricing decisions. firm' Understand the external factors affecting pricing decisions, including the impact of consumer perceptions of pr
UMass (Amherst) - RESEC - 262
Lecture 11: Command and Control Standards Under command and control policies, authorities simply mandate a certain standard of behavior and then use some sort of enforcement strategy to enforce compliance to the mandate. Several Types of Environmenta
UMass (Amherst) - BIOE - 795
Examples of Studies with Possible Clustering Edward J. Stanek III Introduction We present different examples of studies that have potential clustering, and consider representation of a population, a model for the population that defines summary param
UMass (Amherst) - RESEC - 112
GPA Calculator Data NeedsGoal: GPA I would have at the end of this semester, given grade predictions I make.Operational AttunementGPA before this semesterCredits before this semesterGPA this semesterCredits this semesterCourse grade poi
UMass (Amherst) - WFCON - 571
W&amp;F CON 571 EXERCISE 2-MARK-RECAPTURE ESTIMATORS DUE TUESDAY NOVEMBER 2, 2004 Please show ALL your work. 1. Data from a salmonid trapping exercise are given in the tables below. Using this information calculate the following. (Calculate numbers to 6
UMass (Amherst) - BIOEP - 747
PROGRAM:JL03p7.SAS on 21 JAN 2003 by Jingsong LuTable 1. Linear Regression PULSE1 on PULSE0The REG ProcedureModel: MODEL1Dependent Variable: pulse1 Pulse*per min*after*Exercise*PULSE1 Analysis of Variance
UMass (Amherst) - MATH - 233
DEPARTMENT OF MATHEMATICS AND STATISTICS UNIVERSITY OF MASSACHUSETTS MATH 233 EXAM 1 Spring 2007NAME:Section Number: Instructors Name: In problems that require reasoning or algebraic calculation, it is not sucient just to write the answers. You m
UMass (Amherst) - MATH - 233
DEPARTMENT OF MATHEMATICS AND STATISTICS UNIVERSITY OF MASSACHUSETTS MATH 233 NAME: EXAM 1 Fall 2006Section Number:Instructors Name:In problems that require reasoning or algebraic calculation, it is not sucient just to write the answers. You mu
UMass (Amherst) - STAT - 515
UMass (Amherst) - MATH - 233
DEPARTMENT OF MATHEMATICS AND STATISTICS UNIVERSITY OF MASSACHUSETTS MATH 233 EXAM 1 Spring 2006NAME:Section Number:Instructor's Name:In problems that require reasoning or algebraic calculation, it is not sufficient just to write the answers.
UMass (Amherst) - PHYS - 125
Total Internal Reflection Critical Angle q c ni sin q c = nt sin 90o = nt q t &lt; 90ont small ni largeq i&lt; q c q t &gt; 90ont small ni largeq rno transmissionq i&gt; q cq r
UMass (Amherst) - POLSC - 305
Professor Vincent Moscardelli Office: 332 Thompson Hall Office Hrs: MW 2:30-3:30, and by appt. Phone: 545-0416 Email: vmoscardelli@polsci.umass.eduPolitical Science 305 Congress and the Legislative Process Fall 2007 MWF 10:10-11:00; 114 Dickinson H
UMass (Amherst) - POLSC - 101
Political Science 101 Final Examination Review Sheet Spring 2006 (Moscardelli) I. Summary of Assigned Readings The textbook (American Government, by James Q. Wilson) is a custom textbook designed and printed especially for this class. All of the read
UMass (Amherst) - SOM - 640
Chapter 13: The Capital Asset Pricing ModelCopyright Prentice Hall Inc. 1998. Author: Nick Bagley, bdellaSoft, Inc.The Theory of the CAPM Use of CAPM in benchmarking Using CAPM to determine correct rate for 1 discountingObjectiveChapt
UMass (Amherst) - SOM - 640