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

COOSC 236 lecture notes

by: Kelsey Voelker

COOSC 236 lecture notes COSC 236

Marketplace > Towson University > Computer science > COSC 236 > COOSC 236 lecture notes
Kelsey Voelker

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

notes from class lecture on interactive programs
Intro to Computer Science 1
Dr. Alkharouf
Class Notes
25 ?




Popular in Intro to Computer Science 1

Popular in Computer science

This 4 page Class Notes was uploaded by Kelsey Voelker on Friday September 23, 2016. The Class Notes belongs to COSC 236 at Towson University taught by Dr. Alkharouf in Fall 2016. Since its upload, it has received 9 views. For similar materials see Intro to Computer Science 1 in Computer science at Towson University.

Similar to COSC 236 at Towson


Reviews for COOSC 236 lecture 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: 09/23/16
Computer science 1 9/17/16 Lecture notes Interactive Programs using scanner objects Interactive Programs  Written programs that print console output  It is possible to read input from the console o The user types the input into the console o We can capture the input and use it in our program o Such a program is called an interactive program Input and  We print ouput using an object named System.out o This object has methods named println and print.  We read input using an object named o is not intended to be used directly o We will use a second object, from a class called Scanner, to help us read input from (has to be called in a scanner object)  Constructing a Scanner object to read console input: o Scanner <name> = new Scanner(;  Ex. Scanner console = new Scanner(;  Classobject name =  create new object from scanner uses data from keyboard o Once we have constructed the Scanner, we call various methods on it to read the input from user o *class is like a blueprint to create many different objects Scanner methods  nextInt () reads integers from the keyboard  nextDouble () reads decimals  next () reads Strings  each of these methods pauses your program until the user types input and presses Enter o then the value typed is returned to your program  Prompt: a message printed to the user, telling them what input to type, before we read from the Scanner  *can use methods After you create an object  Example: o Import java.util.*; //so that I can use scanner use this for any program asking for user input!! o Must use this for this method use either.* or .scanner in order to use the scanner method and objects o (on BB) o always print user message before the user input o this allows user to put in their information which then gets stored in your code IF Statements  the if statement evaluates a Boolean expression  decides whether a section of code executes or not  if (Boolean expression is true) execute next statement  “if this condition is met, execute the next portion of code” o “is it cold outside?”yes “Wear a coat” o “is it cold outside?”no  a block if statement may be modeled as: o if (coldOutside) o { wearCoat (); o wearHat (); o wearGloves(); o }  *use curly braces to block several statements together  relational operators o <,>,>=,<=,==,!= o greater than, greater than & equal to, not equal to…etc  an if statement can span more than one line, but it is still one statement o  if you separate into two lines…you only need ONE semicolon per statement o if (avg > 95) grade = ‘A’;  use curly braces after if statement (no matter how many statements follow) o otherwise only the first will be connected to the if statement o if statement o { o statement 1, 1, 3; o }  Flags o A flag is a Boolean variable that monitors some condition in a program o When a condition is true, the flag is set to true o Can be tested to see if the condition has changed  If ( average > 95)  highScore = true; Comparing Characters  characters can be tested with relational operators  are stored in memory using the Unicode character format  characters are ordinal meaning they have an order in the Unicode character set o ex. Char c = ‘a’; o if (c <’Z’) o System.out.println(“A is less than Z’); If-else Statements  The if-else statement adds the ability to conditionally execute code when the if condition is false o Ex. If (expression) o statementORBlockIfTrue; o else o statementOrBlockIfFalse; o Ex. If (number2 == 0)  System.out.println (“Division by zero is not possible”);  *does first part if true o Else  System.out.print(“answer”);  *does second part if false Nested if statements  If (coldOutside)  { o if (snowing) o {  wearParka (); o } o else o {  wearJAcket (); o }  }  else  { o wearShorts();  } if-else-if Statements  if multiple expressions true execute codes  else if if first part is not true, and this is  else if nothing above is true, goes here Logical operators  java provides two binary logical operators  AND (&&) takes two operands that must both be Boolean expressions o the resulting combined expression is true if and only If both operands are true  OR (||) o The resulting combined expression is false if and only if both operands are false  NOT ! o If an expression is true, !expression will be false and vice versa Short Circuiting  Java saves time when compiling and will only compile one out of two similar statements Order of precedence  ! comes first  * / %  + -  < > <= >=  == !=  &&  ||  = += -= *= /= %= Comparing String Objects  in most cases, you cannot use relational operators for comparing Strings  methods .equals , .egualsIgnoreCase (true or false/ the same or not) o ex. Name1.eguals (name2)


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."

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."

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."

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.