A Terminal Session - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

A Terminal Session

Description:

A 'Terminal Session' Log In: Username and Password. A window appears. Check the prompt: ... can be anything ' ' is where you type. 4. set prompt ... Illegality ' ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 31
Provided by: cseBu
Category:

less

Transcript and Presenter's Notes

Title: A Terminal Session


1
A Terminal Session
  • Log In Username and Password
  • A window appears
  • Check the prompt
  • some computer name other stuff gt
  • styx.cse.buffalo.edu is the computer, there are
    many.
  • can be anything
  • gt is where you type
  • 4. set prompt / gt

2
Creating Folders (or Subdirectories, or Work
Areas)
  • You type
  • set prompt/ gt
  • eng/home/mikebgt mkdir Lab1
  • eng/home/mikeb gt cd Lab1
  • eng/home/mikeb /Lab1 gt
  • What just happened?
  • eng/home/mikeb /Lab1 gt cd
  • eng/home/mikeb gt

3
Work Areas on the main computer disk

mkdir Lab1 cd Lab1
/
Lab1/
/Lab1 Work Area is the location of edited
files
4
What is a file?
  • Dear John,
  • I think we should just be
  • friends

Created and Saved in an editor eng gt
/util/bin/jgrasp Dearjohn.txt Could be a Java
program eng /Lab1 gt /util/bin/jgrasp
myProgram.java
5
so far
  • We address the computer through a terminal window
    in a primitive language called Unix
  • Unix allows us to set aside private areas of the
    disk and go to them to do our work
  • Once there, we can open, edit, and save files
    which will later become programs
  • Computer Scientists model some aspect of the real
    world in the computer program
  • Computer programs make extensive use of changing
    values called variables.

6
Concatenation (Sequencing)
  • Computers perform one small step at a time, in a
    stated order.
  • z 0
  • x 15
  • y 12
  • z x y
  • print z

7
Variables
  • x, y, z
  • i, j, k
  • TotalCountOfNewEmployees
  • Geekish_Designations_0123
  • They Stand for Something

8
The ESSENCE of a variable
  • a 15
  • b 12
  • c ab What is C?
  • b 1288
  • c ab What is C now?
  • b, and c, are both CHANGEABLE

9
Variable Types (primitive, common)
  • Integers meant to be a whole number (used for
    counting)
  • Floating Pt. meant to be a detailed number
    (used for measuring) called a DOUBLE
  • Character has no meaning other than to be read
    by a human
  • Strings of Characters have no meaning other
    than to be read by a human

10
x 14
  • Could mean 14 (not likely)
  • Could mean 13.999995
  • Could mean 14.000001
  • Could mean 20 (honestly), might not be base-10,
    more later
  • Could mean Fourteen, which has no meaning other
    than to be read by humans

11
Typing a variable
  • Integer X
  • X 14
  • Therefore, 14 means 14
  • Float X (or Real X, or Single X, or Double X)
  • X 14.0000
  • Therefore, X has meaning, 14 to 4 places

12
More
  • Char X, Y
  • X 1
  • Y 4
  • X with Y 14 (Concatenation)
  • String Z
  • Z cat

13
Legality
  • Variable value and variable type must be the
    same.
  • Deterministic behavior - All computers yield the
    same result with the same variables

14
Computers check our programs
  • Called Compilation
  • Must be successful before a program can run

15
Illegality
  • Compiler Errors however, some languages and
    compilers allow mis-designations of variables
  • Indeterminate results
  • Run-time Errors

16
Compilation
will it work?

17
Illegal
  • Integer Y
  • Y 14.001
  • Char Q
  • Q abcdef
  • Double z
  • z hello

18
Why Type Variables
  • Deterministic behavior of variables and the
    numbers they represent.
  • New definition of Legality We will never
    perform mathematical or logical operations on
    variables of different types.

19
Illegal, part 2
  • Integer X
  • Double Y
  • Char Z
  • X 12
  • Y 16.001
  • Z X Y

20
Legal Operation
  • String K
  • Char I, J
  • I H
  • J i
  • K I with J (what is K?)

21
New Types
  • Boolean TRUE or FALSE (really means presence or
    absence), used to signify a condition, or
    state of being.
  • Boolean X, Y, Z
  • X TRUE (means X is present)
  • Y FALSE (means Y is NOT present)
  • Z X OR Y (what is Z?, i.e. does Z signify
    some presence?)
  • Z X AND Y (what is Z?)

22
floating point?
  • 14.6567
  • 128.1231
  • 154367.001423
  • 3.14159
  • 987987465986543.

23
3 categories of ILLEGAL
  • Variables set to a value wrong for its type
  • Integer X
  • X TRUE
  • 2. Variables of different types used in the same
    operation
  • Integer X, Y
  • Char Z
  • Z X Y ( multiply)
  • 3. Operation wrong for variable type
  • String Z cat
  • Q X Z

24
Constants
  • constant integer X
  • or
  • final integer X
  • X 16
  • X 14 illegal!

25
Algorithms
  • Series of mathematical or variable manipulations
  • Integer a,b,c
  • a 12
  • b 22
  • c a b (what is c?)

26
Complicated, Concatenated Algorithms
  • integer Total, LoopCounter
  • Total 0
  • LoopCounter 0
  • Start
  • Add 2 to Total
  • Add 1 to LoopCounter
  • Go Back to Start Until Total 12
  • What is LoopCounter?

two variables
a loop
done
27
Written in Code
  • int LoopCounter, Total
  • LoopCounter 0
  • Total 0
  • while (Total lt 12)
  • Total Total 2
  • LoopCounter LoopCounter 1

semicolon
no semicolon (because brackets follow)
open bracket
odd-looking algebra
close bracket
28
Real code
  • public class Looper
  • public static void main( String args
    )
  • int LoopCounter, Total
  • LoopCounter 0 Total 0 while
    ( Total lt 12 ) Total Total
    2 LoopCounter LoopCounter 1
    System.out.println( LoopCounter )

file
program
loop
Output!
29
Summary
  • Concatenation
  • Typing
  • Legality
  • Algorithm
  • Code

30
Code summary
  • public class filename
  • public static void main( String arg )
  • surround functional paragraphs
  • semicolon
Write a Comment
User Comments (0)
About PowerShow.com