New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Week 3 notes

by: Ankita Upadhyay
Ankita Upadhyay
GPA 4.0
Comp Prog Lab

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

These notes include important programs that might appear on the midterm.
Comp Prog Lab
Class Notes
week 3
25 ?




Popular in Comp Prog Lab

Popular in ComputerScienence

This 5 page Class Notes was uploaded by Ankita Upadhyay on Monday January 25, 2016. The Class Notes belongs to CMPS 12A at University of California - Santa Cruz taught by Tantalo,P. in Winter 2016. Since its upload, it has received 8 views. For similar materials see Comp Prog Lab in ComputerScienence at University of California - Santa Cruz.

Similar to CMPS 12A at UCSC

Popular in ComputerScienence


Reviews for Week 3 notes


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 01/25/16
Lecture 7 12016 More common format review video on matterhorn If cond 1 Stmt Else if cond 2 Stmt Compare1java Ternary conditional operator 0 Cond Exp1 exp2 Ex int x y 6 X y gt 5 1020 x gets 10 Equivalent to Int x y 6 If y gt 5 X 10 Else X 20 This operator can also be cascaded Iterative control structures 0 While for dow while 0 While cond loop repetition condition LRC Stmt loop body stmt Squaresljava example Loop control variable l i1 A very common while loop i 0 l initialize loop control variable lcp While iltn l test LRC do stuff i l increment LCV equivalent for loop for i0 iltn i l mitLCV Test LRC 14CLCV do stuff loop body Ex squaresjava 0 General for of dowhile int variable n int literal Instance vc staticclass method Doubles fed into the pow machine 0 Result is a double which is converted back into an int 0 Note while loop body may execute 0 times but dowhile loop body must execute at least once 0 Logic errors not a syntax error i 0 while ilt10 stuff i l ini nite loop computer will go forever seems broken IE Another logic error fori O i lt 10 i stuff going to execute only once not 10 times trivial cont ved In Ex Averagejava l need a scanner so that the monkey can be heard 0 Sum 0 l accumulator throw gallons of water in a bathtub o Doubleint double quot Maxjava Lecture 9 12216 Ex maxjava review this The scope of a variable is the area of the program where that variable can be accessed In java the scope of a variable extends from its declaration to the end of the block in which it was declared no furtherexamples that illustrate the notion of scope Exscope1Java Scope2java doesn t compile2 different variables names b as long as their scopes don t overlap for int i0 ilt10 i do something end of the scope of i Systemoutprintlni syntax error break and continue commands allow you to take any loop and make it exible to get out of loop make loop repetition condition false general form while cond continue lands here break lands here controlled ways to alter the function of a normal loop checkinput1java how to lter bad input out entered by the user schasnextDouble is an instance method Left of the dot instance method of scanner class hasNext instance method bc you don t see staticpeaks and tells you ahead of time if there s a tokentes whether the program will pause every token is a string entered 2 tokens while pounding bc there was a space int cant be interpreted as double but not every double can be interpreted as int 0 4 is an int 40 is a double CollatzProblemjava Switch statement a conditional operation similar to cascade of else ifs Switchexp case value1 constant expression Stmt Stmt break case value2 stmt break case value 3 stmt break default stmt break llands here Switch1java


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.