×

Let's log you in.

or

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

×

or

36

0

13

Introduction to Computing CSC 116

NCS
GPA 3.94

Suzanne Balik

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

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

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

×
Unlock Preview

COURSE
PROF.
Suzanne Balik
TYPE
Class Notes
PAGES
13
WORDS
KARMA
25 ?

Popular in ComputerScienence

This 13 page Class Notes was uploaded by Jaden Jakubowski on Thursday October 15, 2015. The Class Notes belongs to CSC 116 at North Carolina State University taught by Suzanne Balik in Fall. Since its upload, it has received 36 views. For similar materials see /class/223811/csc-116-north-carolina-state-university in ComputerScienence at North Carolina State University.

×

Reviews for Introduction to Computing

×

×

What is Karma?

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

Date Created: 10/15/15
Boolean Variables Boolean ValuesExpressions Review quotExclusive or vs quotInclusive or De Morgan s Laws Short Circuit Evaluation Logical Operator Precedence Examples TaxCalculator Type boolean boolean A primitive type to represent logical values A boolean expression produces either true or false The ltconditiongts in if statements for loops are boolean Examples boolean minor age lt 21 boolean expensive iPhonePrice gt 50000 boolean iLoveCS true if minor SystemoutprintlnquotCan39t purchase quot quotalcoholquot You can create boolean variables pass boolean parameters return boolean values from methods mquot V Copyright 2006 by Pearson Education Logical operators ampamp II a Boolean expressions can use logical operators Copyright 2006 by Pearson Education Operator Description Example Result ampamp and 9 6 ampamp 2 lt 3 true II or 2 1 lt 5 true 1 not 7 gt 0 false Truth tables of each operator used with boolean values p and q p q p ampampq p H q p p true true true true true false true false false true false true false true false true false false false false quotExclusive or vs quotInclusive or We generally use quotexclusive or when speaking quotI ll do my homework or go to the party means I ll do one or the other but not both Programming uses quotinclusive or An expression is true if either or both conditions are true 2gt34lt5 F T T 2lt34lt5 TTT De Morgan s Laws pampampmunlm NXltWNvlt Xgtvvgtz Hxltyampampyltz De Morgan s Laws pm pampampq xltyampamp yltz Xgty ampamp ygtz Wltvvltz Short Circuit Evaluation Short Circuit Evaluation The property of the logical operators ampamp and I that prevents the second operand from being evaluated if the overall result is obvious from the value of the first operand Examples 2 gt 3 ampamp 4 lt 5 F ampamp F 2lt3 H 4gt5 TT Logical Operator Precedence Not Highest Precedence And ampamp Or Lowest Precedence Example 2lt3 4gt5 ampamp 6gt7 HINT When in doubt use parentheses if Statement Example if xlty true BAD Redundant if x lt y BETTER Method Example if x lt V OK return true else return false return x lt y COOLER Logical Operator Example ifxltY BAD ifylt Z if xltyampampyltz BETTER TaxCalculator Example public static void mainString args Scanner console new ScannerSystemin Systemoutprint Married yn String answer consolenext boolean isMarried false if answerstartsWith y answerstartsWith Y isMarried true Systemoutprint ncome int income consolenextnt double tax calculateTaxisMarried income Systemoutprintf Tax S2fn tax public static double calculateTaxbooean isMarried int income double tax 0 if isMarried else if income lt 16000 tax 10 income else if income lt 64000 tax 1600 15 income 16000 else tax 8800 25 income 64000 if income lt 8000 tax 10 income else if income lt 32000 tax 800 15 income 8000 else tax 4400 25 income 32000 return tax NOTE Class constants should be used instead of magic numbers

×

25 Karma

×

×

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

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Jennifer McGill UCSF Med School

"Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over \$500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Jim McGreen Ohio University

Forbes

"Their 'Elite Notetakers' are making over \$1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!
×

Refund Policy

STUDYSOUP CANCELLATION 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 support@studysoup.com

STUDYSOUP REFUND POLICY

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: support@studysoup.com

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 support@studysoup.com