Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Sequential Execution and Scripts1-26-2011Opening DiscussionMinute EssaysDifficulty of the quiz.Usefulness of hex.Do I play ultimate?Types of escape characters. When to use them.Grade return times.Why both hex and octal?Meaning of A-F I hex.“Number “+8+7 is (“Number “+8)+7Need for commands.VariablesIt is very common to want to represent values with names.A variable is a name that we use to represent a value.In Scala we can declare variables using val or var.val name:Type = expressionvar name:Type = expressionA val can't change it's value, a var can.The colon and type generally optional.TuplesAnother type in Scala is the Tuple type.A tuple has comma separated values in parentheses.They give us a way to handle a fixed set of associated values.Assignment into a tuple does pattern matching.ScriptsWe have spent most of our time in the REPL entering one statement at a time.When we want to do things repeatedly it is nice to put the commands in a file called a script.We can use vi to write a script and put Scala commands in the file.We can run it by specifying the file name after the command scala.Alternately, we can load it into the REPL.Sequential ExecutionWhen you put commands into a script, they are normally executed one after the other from top to bottom.This is what we call sequential execution and it is the default way things happen.Order can be very significant for the instructions in a program.Standard InputScala provides a whole set of functions you can call to read from standard input.readInt()readDouble()readLine()And many moreThis can make your scripts far more useful as they can be used with different values each time you run them.Some ProblemsWe are still a little limited in that we can only do simple math and formatting, but let's try to do some things with that in scripts.We'll start with formatting money.Calculating hourly wages?Taking averages of grades?Suggestions?Minute EssayWhat questions do you have about things?The next IcP is
View Full Document